Programmer's Corner Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Programmer's Corner - Forums


CR to LF conversion help needed

 
Post new topic   Reply to topic    Programmer's Corner Forum Index -> Python
Author Message
sisifos
Grasshopper


Joined: 01 Aug 2007
Posts: 1
Location: Groningen

PostPosted: Wed Aug 01, 2007 10:55 am    Post subject: CR to LF conversion help needed Reply with quote

Hello all,

I am building a data analysis application and i am facing problems to read my data files in different platforms. Originally the text data files are created by an old labview version running on an old mac with macos9 (as far as i can see these text files use only CR as a new line character)

My software is build and runs on python 2.4.4 (running Kubuntu linux) but every time i have to analyze my data i have to manually convert CR to LF with a text editor (i use the tex edit plus on macosX manually converting files one by one then transfering to a usb stick then transfering files to the linux running pc.. Mad ....way to much work...).

The question is how can i search and find for carriage returns in my file and convert them to line feeds (or CR + LF for further use in windows).
I did a bit of searching around but haven't managed to find anyhtong really usefull

Can somebody suggest anything???
Back to top
WannaBe
Wiggles


Joined: 22 Oct 2004
Posts: 714
Location: CA

PostPosted: Fri Aug 03, 2007 1:25 am    Post subject: Reply with quote

You could do a string replacement when loading the file in python.
http://www.devshed.com/c/a/Python/String-Manipulation/

Simply replace crlf (13 & 10) to lf (10), then cr (13) to lf (10).

This would make sure you convert Windows' crlf to Linux's lf, then also spare cr(s) to lf(s).
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Programmer's Corner Forum Index -> Python All times are GMT - 5 Hours
Page 1 of 1

 


Powered by phpBB © 2001, 2002 phpBB Group