reading/writing files in windows

Peter Hansen peter at engcorp.com
Tue Jun 10 08:53:03 EDT 2003


sameer wrote:
> 
> Of course the OS implied is windows (2000 Professional to be exact).
> Moving across a network means that I am dragging the file from my
> computer to shared folder on another computer, both computers being in
> the same domain.  This is just a plain text file.  Then I open the
> file that I transferred using notepad, make some changes to it and
> save and there are no linebreaks at all in the text.  all the lines
> are jumbled together.
> 
> sameer_ at email.com (sameer) wrote in message news:<6bd9f01b.0306090825.37845495 at posting.google.com>...
> > I create files in windows using python.  I have tried using \n and
> > \r\n as the return character and they both work fine.  It's when I
> > move a text file, written by my python program, across a network, open
> > the file and save to it that all the text becomes jumbled up, and all
> > return characters are lost.  How can I make it so this doesn't happen?

Sorry, you'll have to do better.  You still haven't posted any 
example code showing how you "create files ... using python".

Also, by "jumbled" do you simply mean the lines are all joined
together, as though there were no linebreaks at all?  It's better
to be precise when describing a problem that you hope others will
help you debug.

Do you have any program which will let you view the binary contents
of the file after the transfer?

Instead of "dragging" the file, can you use the copy command instead,
both with the /A option and with the /B option?

Are you perhaps having a problem with "binary mode" or not using
binary mode when you create the file in the first place?  You said
you tried both \n and \r\n but without example code, no one can 
possibly know what you are really trying to do.

-Peter




More information about the Python-list mailing list