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 ?

soffcecManagerAsked:
Who is Participating?
 
TommySzalapskiCommented:
There is no way to open sequential LF delimited files in PowerBasic. If you use C++ (getline) or VisualBasic (readline), then you can have it read up to LF not just CRLF.
If you must use PowerBasic, then your only option is to read it in as binary and find the LF characters (which are 10, not 13, my mistake. CR is 13, LF is 10). Or of course to modify the Input file as you have done.

Unfortunately, Powerbasic is fairly limited so those are your only options. To summarize, your options are:
Use a different language
Open in binary
Modify input file
0
 
d4durveshCommented:
refer this,

http://www.cplusplus.com/forum/windows/28103/2/


hope it help you..:-)
0
 
TommySzalapskiCommented:
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.
0
 
soffcecManagerAuthor Commented:
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.
0
 
TommySzalapskiCommented:
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).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.