Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comma Delimited file only reads first field in each record

Status
Not open for further replies.

gstguy

IS-IT--Management
Jul 11, 2002
4
US
I am trying to read a comma delimited (CSV) file in Delphi 3. The record originally had 1434 fields. My original program was in Clipper, which handles files that big. Delphi choked on a record with that many fields. I broke the file up into 250 field chunks. Now it only reads the first field in each record. I have checked for extra characters. There is nothing there. I tried adding a space before the first field.

2 things I need. First if anyone has an idea what might be wrong, please let me know. Second, if anyone knows how you can use a file with records longer than 255 fields, that would be even better. I have a number of Clipper programs with large records.

Thanks for any help from anyone.

GSTGuy
 
I recommend against Pascal file variables.

You could use a TStringList.LoadFromFile and parse each string for commas, or use a TFileStream and read into a buffer and parse that.

How are you reading the files?

Cheers
 
I was trying to read it using the Table component. I was going to use Batchmove to put the info into a Paradox file.

I am not familiar with TFileStream, but it will give me a chance to check it out.

Thanks.

Jim.
 
I would suggest reading the file line by line, as it gives you the opportunity to have a TStringList.CommaText function handle the separation of fields. I does handle double-quotes properly (around fieldvalues), I haven't used it recent enough, so I can't speak for single-quotes surrounding fields.

HTH
TonHu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top