Questions tagged [q-lang]

The q language is a programming language by kx.com for querying kdb+ databases.

Q was developed by Arthur Whitney in 2003 and is built on top of the K programming language. The names q and kdb+ are often used interchangeably, but generally q refers to the programming language and kdb+ refers to the entire runtime environment.

245 questions
1
vote
1 answer

(kdb+/Q language) Creating separate table files from CSV import Parser(edited)

I have a (big) CSV file with some data. And I have a importer from code.kx.com using .Q.fsn colnames:`Symbol`Date`Time`Sequence`Exchange`Type`Level`Condition`Price`Size`BuyerID`SellerID .Q.fsn[{`:newCreatedFile upsert flip…
user2498110
  • 105
  • 1
  • 1
  • 9
1
vote
1 answer

Q/kdb+ read log files by chunk

I have a task that requires me to load log files that is too big for my memory to let it load at once. Therefore I need way to load the file by different chunks.. I know that: -11!(n; filename) loads first n chunk from a file, but how do I load…
user1948847
  • 955
  • 1
  • 12
  • 27
0
votes
2 answers

Addiing rows from from one dataset to another based on certain conditions when all columns name don't match in kdb+

I have two datasets, named data1 and data2. data1 look like: id1 id2 exc1 exc2 exc3 exc4 "aa2" "12ac" 45 54 53 65 "bb" "23" 23 33 23 12 data2 looks like: kid1 id2 sf1 sf2 sf3 sf4 exc1 exc2 "aa2"…
user8415577
0
votes
1 answer

q - apply function on table rowwise

Given a table and a function t:([] c1:1 2 3; c2:`a`b`c; c3:13:00 13:01 13:02) f:{[int;sym;date] symf:{$[x=`a;1;x=`b;2;3]}; datef:{$[x=13:00;1;x=13:01;2;3]}; r:int + symf[sym] + datef[date]; r }; I noticed that when applying the…
tenticon
  • 2,639
  • 4
  • 32
  • 76
0
votes
1 answer

TorQ: How to update disk database populated with .loader.loadallfiles?

I populate a disk database from large CSV files using TorQ's .loader.loadallfiles in a cumulative fashion and it works great. However, I now need to also append data coming from a streaming source and I'm not sure what's the best way to go. I know…
SkyWalker
  • 13,729
  • 18
  • 91
  • 187
0
votes
1 answer

q - filter by group frequencies

I would like to filter a table by a condition on the frequency of groups in a certain column. Example: Given table tmp:([] id:`a`a`b`b`b`c; c2:1 2 3 4 5 6) first find the frequencies of each group ce:count each group tmp[`id] then select the rows…
tenticon
  • 2,639
  • 4
  • 32
  • 76
0
votes
1 answer

Returning a list of tables in kdb

There is a function in kdb generating multiple tables as results. My main aim is to analyze each of the table generated using python. Is there a way I can make it return a list of table or some dictionary of tables so I can export it to python or…
user8415577
0
votes
2 answers

KDB+ using or with where and like

I am trying to get information from column_1 and column_2 for apptype CASPER and FOO. The script works fine when I search for just one or the other apptype. However, when use the 'or' statement to include both apptypes in one output, I get an…
capser
  • 2,442
  • 5
  • 42
  • 74
0
votes
3 answers

Finding dates, omitting weekends and holidays

I'm trying to think of the best way to create a function that avoids using loops/while. Any ideas? Given a function prototype: {[sd;n:hols] / return list of n number of dates <= SD, excluding weekends and hols } Thanks and happy holidays
kenwjj
  • 341
  • 1
  • 7
  • 21
0
votes
3 answers

Find the count of word pairs in kdb+

I have a file which contain multiple rows of item codes as follows. There are 1 million rows similar to these 1. 123,134,256,345,789..... 2. 123,256,345,678,789...... . . I would like to find the count of all the pair of words/items…
Abhinav Choudhury
  • 319
  • 2
  • 3
  • 15
0
votes
1 answer

q - Applying arbitrary function while zipping

in q the dyadic zip operation is done by '. I.e. l1:("a1";"a2") l2:("b1";"b2") (l1,'l2)~("a1b1";"a2b2") I parse this ' as a dyadic operator '[g;l2] where g is a projection of some dyadic function on lists onto a monadic function, e.g. g:,[l1;]. So…
tenticon
  • 2,639
  • 4
  • 32
  • 76
0
votes
3 answers

How do I remove multiple columns from a table?

So there's delete col from table to delete a single column. I suppose I could use over to delete multiple columns. But: I'm not sure if this is efficient at all. I'm not quite sure how to use over correctly here. Something like this doesn't work:…
rgrinberg
  • 9,638
  • 7
  • 27
  • 44
0
votes
2 answers

q kdb matrix multiplication precision

I am doing the matrix multiplication / dot product of two vectors, but losing significant precision in the process. My two tables are: A:flip…
curious
  • 65
  • 5
0
votes
3 answers

Composing symbols in KDB

I'm currently working on a python project that is interacting with a kdb+ database. A future version of the database will have a minor change, and since I can't proceed with my python programming, I thought I'd give it a shot myself instead of…
Karim Stekelenburg
  • 633
  • 12
  • 26
0
votes
2 answers

How do I delete tables matching a search criterion?

I know I can delete tables using delete some_table_name from `. But suppose I have a large number of tables, and want to delete all tables that, say, begin with prefix_ and end with _suffix. How can I do this?
quant
  • 21,507
  • 32
  • 115
  • 211