dc_csv2array()

This forum is for eXpress++ general support.
Post Reply
Message
Author
reganc
Posts: 259
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

dc_csv2array()

#1 Post by reganc »

Roger

This function only looks for linefeeds as line breaks.

If the lines end with carriage return + linefeeds, the carriage return ends up on the end of the last field read.

Are lines in CSV files supposed to only use LF as a line break and not CRLF?
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: dc_csv2array()

#2 Post by rdonnay »

I think I found out that some CSV files don't have CR characters.

Give this a try to see if it solves your problem.

Code: Select all

cCsvFile := Strtran(cCsvFile,Chr(13),'')

aCsv := DC_Csv2Array(cCsvFile)
The eXpress train is coming - and it has more cars.

reganc
Posts: 259
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

Re: dc_csv2array()

#3 Post by reganc »

rdonnay wrote:I think I found out that some CSV files don't have CR characters.

Give this a try to see if it solves your problem.

Code: Select all

cCsvFile := Strtran(cCsvFile,Chr(13),'')

aCsv := DC_Csv2Array(cCsvFile)
Hmm... The CR is not in the filename... :-)

I took a copy of the function code and added a line that does that. So my code is OK.

But I thought maybe you could add something like this after the dc_txtline is called:

Code: Select all

if right(cLine,1) == chr(13)
   cLine:=left(cLine,len(cLine)-1)
endif
as a general fix for this? And you could maybe add a 2nd parameter to control it's usage...
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

Post Reply