See this regex example.
It uses a 10-line subset of the example input
with some LF in quotes.

   load'regex'
   load'files'
   A=: toJ fread 'D:\Math\csv\anon1.csv'
   A
XX,Xxxxxxx,Xxxxxxxx,Xxxx,Xxxxxx,Xxxxxxxx,Xxxxxxx,XX,Xxxxxxx,Xxxxxx Xxxxx,Xxxxxx 
Xxxx
11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: 
Xxxxxxx,Xxxx,X1,"1.1.11-xx","Xxx
11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: 
Xxxxx,Xxxxxxxx,X1,"1.1.11,1.1.11
11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxx: Xxxxxx,Xx 
xxxxxxxx,X1,"1.1","Xxx"
xxxxx xx xxx xxxxx xx xx xxx xx xxxxxxx",Xxxxxxxx,Xxxxx
11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: Xxxxxxx,Xxx x 
Xxx,X1,"","Xxx","X
11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: 
X_X,Xxxxxxxx,X1,"1.1-XX","Xxx","
11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: 
XxxxxxxXxx,Xxxx,X1,"1.1","Xxx","
11111,1111-11-11 11:11:11,1111-11-11 11:11:11,XxXXX Xxxxxxxxx 
XXX,Xxxxxxxx,X1,"1.1.11"
11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: 
Xxxxxxx,Xxxxxxxx,X1,"xxxxx-1.1",
11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: XXX,Xxxx 
Xxxxxxxx,X1,"1.1.11-xxx
(Xxxxx </xxxxxxxx_xxxxxx/ 1.1.1-11.1.1.XXxxx #1 XXX Xxx Xxx 11 11:11:11 XXX 
1111 x11_1

   L=: 0 2 1|:'(?:[^",\n]*|"[^"]*")(?:,[^",\n]*|"[^"]*")*\n' rxmatches A
   ,.L <;.0 A
+-------------------------------------------------------------------------------------
|XX,Xxxxxxx,Xxxxxxxx,Xxxx,Xxxxxx,Xxxxxxxx,Xxxxxxx,XX,Xxxxxxx,Xxxxxx 
Xxxxx,Xxxxxx Xxxx 
+-------------------------------------------------------------------------------------
|11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: 
Xxxxxxx,Xxxx,X1,"1.1.11-xx","Xx
+-------------------------------------------------------------------------------------
|11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: 
Xxxxx,Xxxxxxxx,X1,"1.1.11,1.1.1
+-------------------------------------------------------------------------------------
|11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxx: Xxxxxx,Xx 
xxxxxxxx,X1,"1.1","Xxx
+-------------------------------------------------------------------------------------
|11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: Xxxxxxx,Xxx x 
Xxx,X1,"","Xxx","
+-------------------------------------------------------------------------------------
|11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: 
X_X,Xxxxxxxx,X1,"1.1-XX","Xxx",
+-------------------------------------------------------------------------------------
|11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: 
XxxxxxxXxx,Xxxx,X1,"1.1","Xxx",
+-------------------------------------------------------------------------------------
|11111,1111-11-11 11:11:11,1111-11-11 11:11:11,XxXXX Xxxxxxxxx 
XXX,Xxxxxxxx,X1,"1.1.11
+-------------------------------------------------------------------------------------
|11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: 
Xxxxxxx,Xxxxxxxx,X1,"xxxxx-1.1"
+-------------------------------------------------------------------------------------
|11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxxx: XXX,Xxxx 
Xxxxxxxx,X1,"1.1.11-xx
+-------------------------------------------------------------------------------------
   3{::L <;.0 A
11111,1111-11-11 11:11:11,1111-11-11 11:11:11,Xxxxx: Xxxxxx,Xx 
xxxxxxxx,X1,"1.1","Xxx"
xxxxx xx xxx xxxxx xx xx xxx xx xxxxxxx",Xxxxxxxx,Xxxxx

   M=: 0 2 1|:'(?<=,)(?:"[^"]*"|[^",\n]*)' rxmatches B
   M <;.0 B
+-------------------+-------------------+-------------+-----------+--+-----+-----+----
|1111-11-11 11:11:11|1111-11-11 11:11:11|Xxxxx: Xxxxxx|Xx 
xxxxxxxx|X1|"1.1"|"Xxx"|"Xxx
+-------------------+-------------------+-------------+-----------+--+-----+-----+----
   


--- Jack Andrews <[EMAIL PROTECTED]> wrote:

> oleg wrote:
> >  [Jprogramming] line-oriented I/O?
> >  http://www.jsoftware.com/pipermail/programming/2007-May/006694.html
> 
> i've got free form csv -- newlines (0x0a) in many values.
> 
> surely this is something that j is good at!?
> 
> why does sequential machine (;:) only take array input?  couldn't it
> take a verb that evaluates to the next, say, byte in a stream?  a
> socket, file, terminal...
> 
> 
> ta, jack
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 



      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to