I have a .csv file and I need to manipulate the data based on start or end of a line . How can I find starting point of each line ?
Asked
Active
Viewed 1,303 times
2 Answers
0
It's easiest when you import the file line by line already.
DEFINE VARIABLE cLine AS CHARACTER NO-UNDO.
INPUT FROM yourfile.csv .
REPEAT:
IMPORT UNFORMATTED cLine .
// cLine contains exactly a single line
END.
If the data is more consistent you can even use IMPORT with a DELIMITER insteam of UNFORMATTED.

Mike Fechner
- 6,627
- 15
- 17
0
If it is really a CSV then you can process it very efficiently:
define variable inputItemList as character no-undo extent 128.
define variable i as integer no-undo.
input from value( "yourfile.csv" ).
itemLoop: repeat:
inputItemList = ?.
import delimiter "," inputItemList.
do i = 1 to 128:
if inputItemList[i] = ? then
next itemLoop.
else
do:
/* do something useful with this item... */
end.
end.
end.
input close.
"128" is an arbitrary number of items -- pick something different if you know your data better than I do.
If the data is not all character fields and if it is consistent then you can also use properly typed fields in the IMPORT statement.

Tom Bascom
- 13,405
- 2
- 27
- 33