Topic: Auto Assign fields in csv to text registers? (1 of 2), Read 47 times
Conf: Hints, tips, shortcuts
From: jeremy jacobs
Date: Monday, July 05, 2004 10:35 AM

Can vedit:
1. read a delimited file (tabbed or csv) file line by line
2. from each line assign each field to a text register (i.e start at reg 10 and incrementally assign each field in the delimited file.

The number of fields per line is known (fixed). So manual assignment would be ok. The number of rows vary, so I could use !eof.

I think my baseline question is can a vedit parse a row into fields, and then store into text registers, if so any hints or suggestions on how this might be accomplished would be appreciated.

thanks
jeremy

 


Topic: Auto Assign fields in csv to text registers? (2 of 2), Read 57 times
Conf: Hints, tips, shortcuts
From: Pauli Lindgren
Date: Monday, July 05, 2004 11:28 AM

On 7/5/2004 10:35:47 AM, jeremy jacobs wrote:
>Can vedit:
>1. read a delimited file (tabbed or csv) file line by line

You can handle file line by line with something like

Repeat(ALL) {
// do something for the line
Line(1,ERRBREAK)
}


>2. from each line assign each field to a text register (i.e
>start at reg 10 and incrementally assign each
>field in the delimited file.

The following code reads one line of comma separated fields
into text registers 10, 11, 12, etc.

#10 = 10
while (!AT_eol) {
#11 = Cur_Pos
Search_Block(",",Cur_Pos,EOL_Pos,ERRBREAK+ADVANCE)
Reg_Copy_Block(#10,#11,Cur_Pos-1)
#10++
}
Reg_Copy_Block(#10,Cur_Pos,Eol_Pos)


You should then handle the data in text registers before
reading the next line. (You can not read the whole file into
text registers, since there are only 128 text registers.)

Different approach for handling csv:s can be found in
my HTML table conversion macro HTML_tbl.vdm (in the
HTML Tools package). It converts comma separated (or
Tab separated or whatever) table into HTML table. See:
http://koti.mbnet.fi/pkl/vedit/html.htm#table

--
Pauli