Line Feed in .csv Files

Robin Cook

New Member
I am reading a .csv file into Unix, using CHAR(10) as a delimiter. Does anyone have an idea why the end of some lines contain a line feed, and others don't?
 
Because that's how the file was produced? My understanding of CSV format, is that data is arranged in rows and columns and therefore, a linefeed is essential.

Is is just the linefeed from the last line that is missing? This is fairly common and presents a problem for Progress. The 4GL will not read a line that is not terminated properly.

To get around the problem, before opening the file for input, you can simply append a linefeed to the end of the file. You could check to see whether it already has one by using 4GL 'seek' and READKEY or just add it regardless. The latter case is easier but you'll have to ensure that your importer handles blank lines correctly.

But if you've got linefeeds missing all over the place, then the CSV format is invalid and there's nothing that you can do - unless it's your software that produced the CSV file in the first place.
 
Back
Top