Page 1 of 1
dc_csv2array()
Posted: Tue Sep 13, 2016 4:41 am
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?
Re: dc_csv2array()
Posted: Tue Sep 13, 2016 6:21 am
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)
Re: dc_csv2array()
Posted: Wed Sep 14, 2016 5:07 am
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...