I have recently received a txt file which it appears has LF as the end
of line markets, windows required CRLF
Is there a function call to easily test for this condition before
attempting a append "delimited".
I would be nice if there as an automatic conversion
On Thursday, August 25, 2022 at 2:01:18 AM UTC-7, poopall wrote:
I have recently received a txt file which it appears has LF as the end
of line markets, windows required CRLF
Is there a function call to easily test for this condition before attempting a append "delimited".Read in the "first 1000" characters, and see if any chr(13) are in the string. That should tell you.
I would be nice if there as an automatic conversionThere is, at the source. https://www.hanselman.com/blog/carriage-returns-and-line-feeds-will-ultimately-bite-you-some-git-tips
Might be a "RUN" command / call... https://waterlan.home.xs4all.nl/dos2unix.html
... you'd want the reverse. Might find out what would happen if you always pushed the file (Linux or DOS) through dos2unix first, then back through unix2dos. MIGHT save even doing a check.
David A. Smith
On Friday, 26 August 2022 at 6:32:36 am UTC+10, dlzc wrote:
On Thursday, August 25, 2022 at 2:01:18 AM UTC-7, poopall wrote:
I have recently received a txt file which it appears has LF as the end
of line markets, windows required CRLF
Is there a function call to easily test for this condition before attempting a append "delimited".Read in the "first 1000" characters, and see if any chr(13) are in the string. That should tell you.
I would be nice if there as an automatic conversionThere is, at the source. https://www.hanselman.com/blog/carriage-returns-and-line-feeds-will-ultimately-bite-you-some-git-tips
Might be a "RUN" command / call... https://waterlan.home.xs4all.nl/dos2unix.html
... you'd want the reverse. Might find out what would happen if you always pushed the file (Linux or DOS) through dos2unix first, then back through unix2dos. MIGHT save even doing a check.
David A. SmithThe problem is its not apparent that the .txt file received is in UNIX format, as the CR or LF are hidden symbol.
When dealing with this issue one does not always assume a txt file is anything but CRLF when working in windows, being windows centric.
Many wasted hours thinking I have lost my mind, as only 1st line could be read.
Simple solution for me was to use Notepad++ and convert EOL to Windows
It would be nice if there was a function to check for this condition in a file (hoping someone will create something)
Dear poopall:Thank U, how about a routine that changes all of the to CRLF if they are only LF
On Thursday, August 25, 2022 at 6:21:26 PM UTC-7, poopall wrote:
local cBuffer := ""
local hasCR := .F.
nReadMe := fopen( "Suspect.txt", FO_READ + FO_DENYNONE )
fread( nReadMe, @cBuffer, 1000 ) ;hopefully less than 100 character records hasCR := ( at( chr(13), cBuffer ) > 0 )
fclose( nReadMe )
release cBuffer
... hasCR is true if there is a carriage return.
David A. Smith
On Saturday, 27 August 2022 at 12:15:00 am UTC+10, dlzc wrote:...
Thank U, how about a routine that changes all of the to CRLF
if they are only LF
I have recently received a txt file which it appears has LF as the end of line markets, windows required CRLF
Is there a function call to easily test for this condition before attempting a append "delimited".
I would be nice if there as an automatic conversion
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 439 |
Nodes: | 16 (2 / 14) |
Uptime: | 16:16:22 |
Calls: | 9,148 |
Calls today: | 1 |
Files: | 13,433 |
Messages: | 6,042,395 |