Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

operating system dependent EOF

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi everyone,

does anyone know how I can parse a file, so that it doesn't matter which OS I use?
(in Windows a line ends with CR LF, in LINUX with CR, in OS2 with LF)

I've written a parser under Windows it runs but not under UNIX based systems because the EOL is not found.

Can anyone help me?
 

Right now, the best thing I found is to:
1) detect the kind of EOF used in file (count LF, count CR, compare)
2) convert it to match the EOF expected by my parser.

This way, I'm sure my parser will always react as expected.



The next Python version will handle OS-independent newlines :)
 
I solve the problem by converting "\r" in "\n".
I parse this file (in my case it's a string) again and it works!

> The next Python version will handle OS-independent newlines :)

Bless god! :eek:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top