# Unusual parsing

**URL:** <https://forum.kx.com/t/unusual-parsing/6862>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [January 5, 2011, 10:26pm UTC](https://forum.kx.com/t/unusual-parsing/6862 "2011-01-05T22:26:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick11](https://avatars.discourse-cdn.com/v4/letter/n/54ee81/32.png) [@nick11](https://forum.kx.com/u/nick11)\
**Post date:** [January 5, 2011, 10:26pm UTC](https://forum.kx.com/t/unusual-parsing/6862/1 "2011-01-05T22:26:00Z")

</div>

I’m currently working on a project to make a database of hands ofonline poker games. I have a lot of the data saved down in text filesand was wondering how to parse it out in q to a stage where I canstart taking the data and inserting it into tables. I’m in the earlystages of this project so any pointers would be appreciated!A typical file would be:#Game No : 75650248\*\*\*\*\* Cassava Hand History for Game 75650248 \*\*\*\*\*$0.50/$1 Blinds No Limit Holdem - \*\*\* 05 01 2011 21:17:31Table Grenoble (Real Money)Seat 5 is the buttonTotal number of players : 8Seat 2: TREVOXO ( $56.55 )Seat 3: Extravis ( $124.22 )Seat 4: kumberl ( $66.85 )Seat 5: luckbox\_babe ( $81.50 )Seat 7: Ravenking ( $102.13 )Seat 8: BUQ666 ( $94.50 )Seat 9: c.o.double.d ( $104.36 )Seat 10: 73BF93 ( $145.16 )Ravenking posts small blind [$0.50]BUQ666 posts big blind [$1]\*\* Dealing down cards \*\*c.o.double.d folds73BF93 foldsTREVOXO foldsExtravis foldskumberl calls [$1]luckbox\_babe raises [$4]Ravenking foldsBUQ666 foldskumberl calls [$3]\*\* Dealing flop \*\* [Ad, 7d, 3h]kumberl checksluckbox\_babe bets [$6.50]kumberl calls [$6.50]\*\* Dealing turn \*\* [5s]kumberl checksluckbox\_babe checks\*\* Dealing river \*\* [8c]kumberl bets [$22.50]luckbox\_babe calls [$22.50]\*\* Summary \*\*kumberl shows [6d, 9d]luckbox\_babe mucks [Jd, Ac]kumberl collected [$64.13]At the minute I’m usingdata: “c”$read1 `:hands.txtWhich loads in multiple hands similar to the above as one long string.Q1)Is there a way in q to break this up into individual messages when thehash symbol appears as this is the symbol indicating a new hand isbeginning?I've trieddata: ("C"; enlist "#") read0 `:hands.txtWhich is similar to what I’ve used to read in csv files before, itjust returns a load of junk.Q2)Once I’ve broken it up into a strings for each hand, is it possible tostart running functions on the data at key words. The message formathere is:Players name | Action | Amount (if a bet was placed)Because player names are all different lengths I wasn’t sure how tostart going about selecting the name from the string and then sayupdate their action to Bet $x in my database.If anyone is interested in getting involved in the project drop me anemail. My speciality is poker rather than programming so wouldappreciate the knowledge!Cheers,Nick

---

<div class="post-metadata">

**Author:** ![manni\_patel](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@manni\_patel](https://forum.kx.com/u/manni_patel)\
**Post date:** [January 5, 2011, 11:06pm UTC](https://forum.kx.com/t/unusual-parsing/6862/2 "2011-01-05T23:06:00Z")

</div>

UGFyc2luZyB0aGF0IGZpbGUgaW4gcSB3b3VsZCBiZSAgbW9yZSBkaWZmaWN1bHQgdGhhbiwgc2F5  
LCB3cml0aW5nIGEgcGVybCBzY3JpcHQgdG8gZHVtcCBhIG1vcmUgcmVndWxhciBsb29raW5nIGZp  
bGUuDQoNCk90aGVyd2lzZSB5b3VyIHRleHQgcmVhZCBpcyB0aGUgcmlnaHQgc3RhcnQsIGFuZCB5  
b3UgZmluZCB5b3UnbGwgbmVlZCB0byBkbyBsb3RzIG9mIG5lc3RlZCBpZi9saWtlL3ZzIGNhbGxz  
Lg0KDQoNClNlbnQgdXNpbmcgQmxhY2tCZXJyea4gZnJvbSBPcmFuZ2UNCg0KLS0tLS1PcmlnaW5h  
bCBNZXNzYWdlLS0tLS0NCkZyb206IE5pY2sgPG5pY2ttY2RhaWRAZ21haWwuY29tPg0KU2VuZGVy  
OiBwZXJzb25hbC1rZGJwbHVzQGdvb2dsZWdyb3Vwcy5jb20NCkRhdGU6IFdlZCwgNSBKYW4gMjAx  
MSAxNDoyNjoxNyANClRvOiBL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  
dCBzZWxlY3RpbmcgdGhlIG5hbWUgZnJvbSB0aGUgc3RyaW5nIGFuZCB0aGVuIHNheQ0KdXBkYXRl  
IHRoZWlyIGFjdGlvbiB0byBCZXQgJHggaW4gbXkgZGF0YWJhc2UuDQoNCg0KDQoNCklmIGFueW9u  
ZSBpcyBpbnRlcmVzdGVkIGluIGdldHRpbmcgaW52b2x2ZWQgaW4gdGhlIHByb2plY3QgZHJvcCBt  
ZSBhbg0KZW1haWwuIE15IHNwZWNpYWxpdHkgaXMgcG9rZXIgcmF0aGVyIHRoYW4gcHJvZ3JhbW1p  
bmcgc28gd291bGQNCmFwcHJlY2lhdGUgdGhlIGtub3dsZWRnZSENCg0KQ2hlZXJzLA0KDQpOaWNr  
DQoNCg0KLS0gDQpZb3UgcmVjZWl2ZWQgdGhpcyBtZXNzYWdlIGJlY2F1c2UgeW91IGFyZSBzdWJz  
Y3JpYmVkIHRvIHRoZSBHb29nbGUgR3JvdXBzICJLZGIrIFBlcnNvbmFsIERldmVsb3BlcnMiIGdy  
b3VwLg0KVG8gcG9zdCB0byB0aGlzIGdyb3VwLCBzZW5kIGVtYWlsIHRvIHBlcnNvbmFsLWtkYnBs  
dXNAZ29vZ2xlZ3JvdXBzLmNvbS4NClRvIHVuc3Vic2NyaWJlIGZyb20gdGhpcyBncm91cCwgc2Vu  
ZCBlbWFpbCB0byBwZXJzb25hbC1rZGJwbHVzK3Vuc3Vic2NyaWJlQGdvb2dsZWdyb3Vwcy5jb20u  
DQpGb3IgbW9yZSBvcHRpb25zLCB2aXNpdCB0aGlzIGdyb3VwIGF0IGh0dHA6Ly9ncm91cHMuZ29v  
Z2xlLmNvbS9ncm91cC9wZXJzb25hbC1rZGJwbHVzP2hsPWVuLg0KDQo=

---

<div class="post-metadata">

**Author:** ![k\_os\_tao](https://avatars.discourse-cdn.com/v4/letter/k/a9a28c/32.png) [@k\_os\_tao](https://forum.kx.com/u/k_os_tao)\
**Post date:** [January 5, 2011, 11:54pm UTC](https://forum.kx.com/t/unusual-parsing/6862/3 "2011-01-05T23:54:00Z")

</div>

Nick,pls send me a list of inputs and the desired outputs and I’ll give ita try`k.osOn Jan 5, 5:26?pm, Nick <nickmcd...> wrote:&gt; I'm currently working on a project to make a database of hands of&gt; online poker games. I have a lot of the data saved down in text files&gt; and was wondering how to parse it out in q to a stage where I can&gt; start taking the data and inserting it into tables. I'm in the early&gt; stages of this project so any pointers would be appreciated!&gt;&gt; A typical file would be:&gt;&gt; #Game No : 75650248&gt; *****Cassava Hand History for Game 75650248***** &gt; $0.50/$1 Blinds No Limit Holdem - ***05 01 2011 21:17:31&gt; Table Grenoble (Real Money)&gt; Seat 5 is the button&gt; Total number of players : 8&gt; Seat 2: TREVOXO ( $56.55 )&gt; Seat 3: Extravis ( $124.22 )&gt; Seat 4: kumberl ( $66.85 )&gt; Seat 5: luckbox_babe ( $81.50 )&gt; Seat 7: Ravenking ( $102.13 )&gt; Seat 8: BUQ666 ( $94.50 )&gt; Seat 9: c.o.double.d ( $104.36 )&gt; Seat 10: 73BF93 ( $145.16 )&gt; Ravenking posts small blind [$0.50]&gt; BUQ666 posts big blind [$1]&gt;** Dealing down cards **&gt; c.o.double.d folds&gt; 73BF93 folds&gt; TREVOXO folds&gt; Extravis folds&gt; kumberl calls [$1]&gt; luckbox_babe raises [$4]&gt; Ravenking folds&gt; BUQ666 folds&gt; kumberl calls [$3]&gt;** Dealing flop **[Ad, 7d, 3h]&gt; kumberl checks&gt; luckbox_babe bets [$6.50]&gt; kumberl calls [$6.50]&gt;** Dealing turn **[5s]&gt; kumberl checks&gt; luckbox_babe checks&gt;** Dealing river **[8c]&gt; kumberl bets [$22.50]&gt; luckbox_babe calls [$22.50]&gt;** Summary **&gt; kumberl shows [6d, 9d]&gt; luckbox_babe mucks [Jd, Ac]&gt; kumberl collected [$64.13]&gt;&gt; At the minute I'm using&gt; data: "c"$read1 `:hands.txt\>\> Which loads in multiple hands similar to the above as one long string.\>\> Q1)\> Is there a way in q to break this up into individual messages when the\> hash symbol appears as this is the symbol indicating a new hand is\> beginning?\>\> I’ve tried\> data: (“C”; enlist “#”) read0 `:hands.txt\> Which is similar to what I’ve used to read in csv files before, it\> just returns a load of junk.\>\> Q2)\> Once I’ve broken it up into a strings for each hand, is it possible to\> start running functions on the data at key words. The message format\> here is:\>\> Players name ?| ?Action | Amount (if a bet was placed)\>\> Because player names are all different lengths I wasn’t sure how to\> start going about selecting the name from the string and then say\> update their action to Bet $x in my database.\>\> If anyone is interested in getting involved in the project drop me an\> email. My speciality is poker rather than programming so would\> appreciate the knowledge!\>\> Cheers,\>\> Nick\</nickmcd…\>

---

<div class="post-metadata">

**Author:** ![Aaron\_Davies](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@Aaron\_Davies](https://forum.kx.com/u/Aaron_Davies)\
**Post date:** [January 6, 2011, 5:14am UTC](https://forum.kx.com/t/unusual-parsing/6862/4 "2011-01-06T05:14:00Z")

</div>



---

<div class="post-metadata">

**Author:** ![nick11](https://avatars.discourse-cdn.com/v4/letter/n/54ee81/32.png) [@nick11](https://forum.kx.com/u/nick11)\
**Post date:** [January 8, 2011, 6:02pm UTC](https://forum.kx.com/t/unusual-parsing/6862/5 "2011-01-08T18:02:00Z")

</div>

Thanks to all for the help with that!On Jan 6, 5:14?am, Aaron Davies \<aaron.dav…\> wrote:\> On Jan 5, 2011, at 5:26 PM, Nick wrote:\>\>\>\>\>\>\>\>\>\> \> I’m currently working on a project to make a database of hands of\> \> online poker games. I have a lot of the data saved down in text files\> \> and was wondering how to parse it out in q to a stage where I can\> \> start taking the data and inserting it into tables. I’m in the early\> \> stages of this project so any pointers would be appreciated!\>\> \> A typical file would be:\>\> \> #Game No : 75650248\> \> _ **Cassava Hand History for Game 75650248** _ \> \> $0.50/$1 Blinds No Limit Holdem - _**05 01 2011 21:17:31\> \> Table Grenoble (Real Money)\> \> Seat 5 is the button\> \> Total number of players : 8\> \> Seat 2: TREVOXO ( $56.55 )\> \> Seat 3: Extravis ( $124.22 )\> \> Seat 4: kumberl ( $66.85 )\> \> Seat 5: luckbox\_babe ( $81.50 )\> \> Seat 7: Ravenking ( $102.13 )\> \> Seat 8: BUQ666 ( $94.50 )\> \> Seat 9: c.o.double.d ( $104.36 )\> \> Seat 10: 73BF93 ( $145.16 )\> \> Ravenking posts small blind [$0.50]\> \> BUQ666 posts big blind [$1]\> \>** Dealing down cards **\> \> c.o.double.d folds\> \> 73BF93 folds\> \> TREVOXO folds\> \> Extravis folds\> \> kumberl calls [$1]\> \> luckbox\_babe raises [$4]\> \> Ravenking folds\> \> BUQ666 folds\> \> kumberl calls [$3]\> \>** Dealing flop **[Ad, 7d, 3h]\> \> kumberl checks\> \> luckbox\_babe bets [$6.50]\> \> kumberl calls [$6.50]\> \>** Dealing turn **[5s]\> \> kumberl checks\> \> luckbox\_babe checks\> \>** Dealing river **[8c]\> \> kumberl bets [$22.50]\> \> luckbox\_babe calls [$22.50]\> \>** Summary **\> \> kumberl shows [6d, 9d]\> \> luckbox\_babe mucks [Jd, Ac]\> \> kumberl collected [$64.13]\>\> \> At the minute I’m using\> \> data: “c”$read1 `:hands.txt&gt;&gt; &gt; Which loads in multiple hands similar to the above as one long string.&gt;&gt; &gt; Q1)&gt; &gt; Is there a way in q to break this up into individual messages when the&gt; &gt; hash symbol appears as this is the symbol indicating a new hand is&gt; &gt; beginning?&gt;&gt; &gt; I've tried&gt; &gt; data: ("C"; enlist "#") read0 `:hands.txt\> \> Which is similar to what I’ve used to read in csv files before, it\> \> just returns a load of junk.\>\> that pair left argument is only applicable to 0: (and 1:); read0 is a monadic function, so you’re applying the string result of it to the list (“C”;enlist"#“), which is not at all what you want to do\>\> read1 is for binary data and is unnecessary here; read0 will be fine\>\> q)data:read0`:hands.txt&gt; q)data:(where"#"=first each data)cut data&gt;&gt; this gives you a matrix of hands&gt;&gt; (an alternative would be&gt;&gt; q)data:1_` vs’”#“vs"c”$read1`:hands.txt&gt;&gt; which would give you the same thing except without the hashes on the "Game No" lines)&gt;&gt; &gt; Q2)&gt; &gt; Once I've broken it up into a strings for each hand, is it possible to&gt; &gt; start running functions on the data at key words. The message format&gt; &gt; here is:&gt;&gt; &gt; Players name ?| ?Action | Amount (if a bet was placed)&gt;&gt; &gt; Because player names are all different lengths I wasn't sure how to&gt; &gt; start going about selecting the name from the string and then say&gt; &gt; update their action to Bet $x in my database.&gt;&gt; you can tokenize by splitting on spaces&gt;&gt; the simpler the language you're parsing the easier the code is--e.g. the post-deal actions all seem to be one word, which helps, but the pre-deal ones aren't, and the spaces in the cards and money formats complicate things as well&gt;&gt; what follows is a couple ways to generate a table of player actions, handling both cards and money&gt;&gt; here's one approach given the input format you have:&gt;&gt; isolate the post-deal player actions:&gt;&gt; q)actions:{{x where not"*"=first each x}{(first where x like"*Dealing*")_x}x}each data&gt;&gt; then parse each action, accounting for all the formatting inconsistencies:&gt;&gt; q)t:([]game:`int$();player:`$();action:`$();cards:();amount:`float$())&gt; q)games:"I"$last each" "vs'first each data&gt; q)process:{$["["in y;$["$"in v:(y?"[")_y;(enlist`amount)!enlist"F"$v except"$[]";(enlist`cards)!enlist trim v];()],`game`player`action!x,`$2#" "vs y}&gt; q)`t upsert’‘games process’'actions;\>\> which gives you\>\> q)t\> game ? ? player ? ? ? action ? ?cards ? ? ? ?amount\> ---------------------------------------------------\> 75650248 c.o.double.d folds ? ? () ? ? ? ? ? ? ? ?\> 75650248 73BF93 ? ? ? folds ? ? () ? ? ? ? ? ? ? ?\> 75650248 TREVOXO ? ? ?folds ? ? () ? ? ? ? ? ? ? ?\> 75650248 Extravis ? ? folds ? ? () ? ? ? ? ? ? ? ?\> 75650248 kumberl ? ? ?calls ? ? () ? ? ? ? ? 1 ? ?\> 75650248 luckbox\_babe raises ? ?() ? ? ? ? ? 4 ? ?\> 75650248 Ravenking ? ?folds ? ? () ? ? ? ? ? ? ? ?\> 75650248 BUQ666 ? ? ? folds ? ? () ? ? ? ? ? ? ? ?\> 75650248 kumberl ? ? ?calls ? ? () ? ? ? ? ? 3 ? ?\> 75650248 kumberl ? ? ?checks ? ?() ? ? ? ? ? ? ? ?\> 75650248 luckbox\_babe bets ? ? ?() ? ? ? ? ? 6.5 ?\> 75650248 kumberl ? ? ?calls ? ? () ? ? ? ? ? 6.5 ?\> 75650248 kumberl ? ? ?checks ? ?() ? ? ? ? ? ? ? ?\> 75650248 luckbox\_babe checks ? ?() ? ? ? ? ? ? ? ?\> 75650248 kumberl ? ? ?bets ? ? ?() ? ? ? ? ? 22.5 ?\> 75650248 luckbox\_babe calls ? ? () ? ? ? ? ? 22.5 ?\> 75650248 kumberl ? ? ?shows ? ? “[6d, 9d]” ? ? ?\> 75650248 luckbox\_babe mucks ? ? “[Jd, Ac]” ? ? ?\> 75650248 kumberl ? ? ?collected () ? ? ? ? ? 64.13\>\> this solution is mostly just an exercise to help demonstrate how to handle irregular text in q\>\> if you have any control over the input format, something more regular would be easier to work with, like this:\>\> % cat hands.csv\> game,k,v0,v1,v2\> 75650248,variant,$0.50/$1 Blinds No Limit Holdem\> 75650248,date,05 01 2011 21:17:31\> 75650248,table,Grenoble (Real Money)\> 75650248,button,5\> 75650248,players,8\> 75650248,seat,2,TREVOXO,56.55\> 75650248,seat,3,Extravis,124.22\> 75650248,seat,4,kumberl,66.85\> 75650248,seat,5,luckbox\_babe,81.50\> 75650248,seat,7,Ravenking,102.13\> 75650248,seat,8,BUQ666,94.50\> 75650248,seat,9,c.o.double.d,104.36\> 75650248,seat,10,73BF93,145.16\> 75650248,sBlind,Ravenking,0.50\> 75650248,bBlind,BUQ666,1\> 75650248,down\> 75650248,act,fold,c.o.double.d\> 75650248,act,fold,73BF93\> 75650248,act,fold,TREVOXO\> 75650248,act,fold,Extravis\> 75650248,act,call,kumberl,1\> 75650248,act,raise,luckbox\_babe,4\> 75650248,act,fold,Ravenking\> 75650248,act,fold,BUQ666\> 75650248,act,call,kumberl,3\> 75650248,flop,Ad7d3h\> 75650248,act,check,kumberl\> 75650248,act,bet,luckbox\_babe,6.50\> 75650248,act,call,kumberl,6.50\> 75650248,turn,5s\> 75650248,act,check,kumberl\> 75650248,act,check,luckbox\_babe\> 75650248,river,8c\> 75650248,act,bet,kumberl,22.50\> 75650248,act,call,luckbox\_babe,22.50\> 75650248,summary\> 75650248,act,show,kumberl,6d9d\> 75650248,act,muck,luckbox\_babe,JdAc\> 75650248,act,collect,kumberl,64.13\>\> you can then generate the same table much more easily:\>\> q)data:("IS**_";enlist",")0:`:hands.csv&gt; q)t:([]game:`int$();player:`$();action:`$();cards:();amount:`float$())&gt; q)actions:update action:`$v0 from select from data where k=`act&gt; q)`t upsert select game,action,player:`$v1,cards:?[action in`show`muck;`$2 cut’v2;count[i]#()],amount:?[action in`bet`raise`call`collect;“F”$v2;0n]from actions;\> q)t\> game ? ? player ? ? ? action ?cards ?amount\> -------------------------------------------\> 75650248 c.o.double.d fold ? ?() ? ? ? ? ?\> 75650248 73BF93 ? ? ? fold ? ?() ? ? ? ? ?\> 75650248 TREVOXO ? ? ?fold ? ?() ? ? ? ? ?\> 75650248 Extravis ? ? fold ? ?() ? ? ? ? ?\> 75650248 kumberl ? ? ?call ? ?() ? ? 1 ? ?\> 75650248 luckbox\_babe raise ? () ? ? 4 ? ?\> 75650248 Ravenking ? ?fold ? ?() ? ? ? ? ?\> 75650248 BUQ666 ? ? ? fold ? ?() ? ? ? ? ?\> 75650248 kumberl ? ? ?call ? ?() ? ? 3 ? ?\> 75650248 kumberl ? ? ?check ? () ? ? ? ? ?\> 75650248 luckbox\_babe bet ? ? () ? ? 6.5 ?\> 75650248 kumberl ? ? ?call ? ?() ? ? 6.5 ?\> 75650248 kumberl ? ? ?check ? () ? ? ? ? ?\> 75650248 luckbox\_babe check ? () ? ? ? ? ?\> 75650248 kumberl ? ? ?bet ? ? () ? ? 22.5 ?\> 75650248 luckbox\_babe call ? ?() ? ? 22.5 ?\> 75650248 kumberl ? ? ?show ? ?`6d`9d ? ? ?\> 75650248 luckbox\_babe muck ? ?`Jd`Ac ? ? ?\> 75650248 kumberl ? ? ?collect () ? ? 64.13\</aaron.dav…\>
