soffcec
asked on
Read Unix file with Powerbasic 6.0
How can I read LINUX/UNIX text file who has only Linefeed (LF) as terminator not Linefeed/Carriage return (CRLF) as Powerbasic uses ?
Um, that's C++ not Powerbasic.
If you want to open the file using Powerbasic, just open it as a BINARY instead of a READ file.
http://www.powerbasic.com/support/help/pbcc/open_statement.htm
Then you can read in the file one character at a time and when you get to a character with a value of 13, that's the LF character.
If you want to open the file using Powerbasic, just open it as a BINARY instead of a READ file.
http://www.powerbasic.com/support/help/pbcc/open_statement.htm
Then you can read in the file one character at a time and when you get to a character with a value of 13, that's the LF character.
ASKER
I am reading files who are more than 1 Gb. in size with few millions records. I think open and read as binary will take to long time. Today I read the whole file and replace LF with CRLF with "REPLACE $LF with $CRLF" and then I write it out again, then after I can read it in record for record. I am looking for more simple way to do this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I don't think reading as binary is any slower. In either case you or the background code needs to find the line terminating character. If the compiler optimizes properly, they should run at the same speed (just take some extra work programming).
http://www.cplusplus.com/forum/windows/28103/2/
hope it help you..:-)