Google Groups unterstützt keine neuen Usenet-Beiträge oder ‑Abos mehr. Bisherige Inhalte sind weiterhin sichtbar.

FileRead in LineMode and Parse data into individual column

581 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Mary

ungelesen,
20.10.2004, 05:47:2120.10.04
an
Dear All:

Anybody could suggest or advices:

I want to read a csv file and process the records in the csv
file row by row.

I used the fileopen() in linemode and the fileread(). As
scrip below

FileLength("C:\test.csv")

FileOpen("C:\test.csv",LineMode! )

The question are:
1. How to code so the it will process read records in
test.csv file until last records?
2. How to parse the data into individual column which
seperated by comma?

e.g: records in the csv file consist of 5 columns

1,Jane,ykzbsdbsdfsfsf,XX,,
2,dhsdjsdds djfjsjss,123,00,jlkmnb
3,,654334,hbjjjjjjjjj,ertdss

Thanks

Bob Chauvin ( Paix dehors )

ungelesen,
20.10.2004, 08:41:5920.10.04
an
How many rows do you expect to be in the file?

--
PB9.01.7236
Thank you,

R.Chauvin
<Mary> wrote in message news:41763429.76d...@sybase.com...

Mark

ungelesen,
20.10.2004, 09:22:5020.10.04
an
There are several ways you could go about this.
Read line by line as a line sequential file, open with ODBC Text driver and
run SQL statements on it or even do the way you are doing with filelength()
but I would say the filelenth() method is the most complicated, since you
got to know the lenghth of each record and divide this number into the file
length keeping in mind that the length might not be an exact multiple of the
record length. Also if each record is not of a fixed length you migiht run
into trouble. I would use fileread()s.

About parsing the data into indivicual columns, you can check for commas.
Even easier would be to just import the file into a datawindow and then do
all your processing from the datawindow. This is the way I would go.

Mark


<Mary> wrote in message news:41763429.76d...@sybase.com...

Mary

ungelesen,
20.10.2004, 21:50:0720.10.04
an
migth be few thousand records

Bob Chauvin ( Paix dehors )

ungelesen,
21.10.2004, 09:30:4121.10.04
an
The reason I ask is if ImportFile is *(IMHO) the easier way to read in data.
The down side is that ImportFile reads entire file into the datastore, which
can be a drain on memory, and performance.

You have to decide which method is appropriate. Both are do-able.


--
PB9.01.7236
Thank you,

R.Chauvin
<Mary> wrote in message news:417715c9.7b0...@sybase.com...

0 neue Nachrichten