--
You received this message because you are subscribed to the Google Groups "Kona Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kona-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kona-user/2f1fdf99-2bba-4c0a-90a9-2418ec31a392n%40googlegroups.com.
("ICF";",")0:`a.csv
(,1
,"alpha"
,2.0)
("ICF";,",")0:`b.csv
(`num `str `real
(,1
,"alpha"
,2.0))
The CSV files are:
===> cat a.csv
1,alpha,2.0
===> cat b.csv
num,str,real
1,alpha,2.0
Oh, wow. It works for me too. Thanks for that. I'm still new
to kona so maybe I over interpreted the errors I ran into. It
looks like it's still having issues with quoting though.
➜ kona git:(master) ✗ cat quote.csv
she,asked,"""why not now?"""
➜ kona git:(master) ✗ rlwrap ./k
kona \ for help. \\ to exit.
("CCC";",")0:`quote.csv
(,"she"
,"asked"
,"\"\"\"why not now?\"\"\"\r")
FWIW, here's what I have for trying to mask out quotes in order
to not split on separators in quotes, but I'll have a look at
Kevin's references from another post. I think this is relatively
fast as the number of converge steps is only as long as the
longest string of consecutive quotes which shouldn't be long.
tbl:("CCC";",")0:`quote.csv
","/*:'tbl
"she,asked,\"\"\"why not now?\"\"\"\r"
txt:","/*:'tbl
q:"\""=txt
rmpr:{{ls:{{*-2#(|/)({{x _ (b&1!b:(0,y))}[x]y}[x])\y}\:[-1
1;x]}x;c:-/*:'&:'ls;x&~|/((-!(c!2)+c)!\:*|ls)}/x}
(q; rmpr q)
(0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0)
txt:"\"that\",\"guy\",\"said, \"\"hi\"\" to
\"\"me\"\"\",\"why?\""
q:"\""=txt
(q; rmpr q)
(1 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 1 1 0
0 1 1 1 0 1 0 0 0 0 1
1 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 1 0 0 0 0 1)
The next step is to turn this into masked regions of in an out of
quotes.
--
You received this message because you are subscribed to a topic in the Google Groups "Kona Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kona-user/53T4Rzt_STQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kona-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kona-user/7bb058bc-8253-4343-8cdb-0653dc8021bbn%40googlegroups.com.
FWIW, here's a first cut at quote handling for a csv. It likely
breaks pretty bad when the csv is not well formatted, but I'm not
sure what should be expected in that case.
➜ kona git:(master) ✗ rlwrap ./k
kona \ for help. \\ to exit.
sp:{(0,(&x)-!#&x) _ y[&~x]}
rm:{{ls:1_-1!(/|){-1 _
(b&1!b:(0,x))}\x;c:#ls;(x&~|/((c!2)+!c-(c!2))!\:*|ls)}/x}
ma:{wh:-':(&x),(#x);,/{(x[0]+-1+2*c)#c:~x[1]}'+:(wh;(!#wh)!\:2)}
uq:{bs:"\""=x;c:|/bs;rm:({1_
b&-1!b:(0,x)}bs);x[&~rm|c*f||f:~!#x]}
snq:{qs:"\""=y;qm:ma[rm[qs]];s:(~qm)&x=y;sp[s;y]}
csv:{uq''snq[","]'snq["\n"]x}
txt:"\"this\",\"guy\",\"said, \"\"hi\"\"
to \"\"me\"\"\",\"sad\"\n\"this\",\"guy\",\"said, \"\"hi\"\" to
\"\"me\"\"\",\"sad\""
csv txt
(("this"
"guy"
"said, \"hi\" to \"me\""
"sad")
("this"
"guy"
"said, \"hi\" to \"me\""
"sad"))
Better! I can just take the running sum of the index function of
where the quotes are and look at the parity to generate the mask
directly instead of my "fancy" construction below. I also changed
split because the previous version didn't handle empty fields.
qm:{s|((+\s:(x=y))!\:2)}
sp:{(,*l),1_/:1_ l:((0,&x) _ y)}
uq:{bs:"\""=x;c:|/bs;rm:({1_
b&-1!b:(0,x)}bs);x[&~rm|c*f||f:~!#x]}
snq:{m:qm["\""][y];s:(~m)&x=y;sp[s;y]}
csv:{uq''snq[","]'snq["\n"]x}
csv txt
(("this"
"guy"
"said, \"boo\" to \"me\""
"why?")
("this"
"guy"
"said, \"boo\" to \"me\""
"why?"))
FWIW, I'm a little worried about this being spam but the traffic here is pretty low. Please feel free to redirect me to a more appropriate outlet.
To view this discussion on the web visit https://groups.google.com/d/msgid/kona-user/a95d26fe-8859-4f66-b72a-f616217e04a0n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kona-user/8a78a3eb-0300-460b-91b9-3989c7a325a0n%40googlegroups.com.