Re: Reading and writing to a file creates null characters

2012-01-13 Thread Denhua
On Jan 12, 6:21 pm, MRAB wrote: > On 12/01/2012 22:26, Denhua wrote: > > > > > > > > > Hi, > > > I've got a file which I'd like to read, modify and write. > > > # file contents > > a > > b > > c > > d > > > My script reads the file contents into a list and rotates the list and > > writes it back t

Re: Reading and writing to a file creates null characters

2012-01-12 Thread MRAB
On 12/01/2012 22:26, Denhua wrote: Hi, I've got a file which I'd like to read, modify and write. # file contents a b c d My script reads the file contents into a list and rotates the list and writes it back to the same file. Problem is that the output contains null characters. I don't know whe

Re: Reading and writing to a file creates null characters

2012-01-12 Thread Roy Smith
In article <4f7d125a-2713-4b57-a108-2a56ae653...@h3g2000yqe.googlegroups.com>, Denhua wrote: > [omitted] > f.write("\n".join(newlist)) > f.close() > > # output > > [root@Inferno html]# python rotate.py > ['b', 'c', 'd', 'a'] > [root@Inferno html]# python rotate.py > ['c', 'd', 'a', '\x00\x00\

Re: reading and writing files

2011-08-23 Thread Chris Rebert
On Tue, Aug 23, 2011 at 11:29 PM, Muresan Alexandru Mihai wrote: > If you need an int isn't better to use input() instead of raw_input() ? Absolutely not! input() does an eval(), which is very dangerous security-wise and can also lead to rather strange behavior. input() is so bad that it was remo

Re: reading and writing files

2011-08-23 Thread Muresan Alexandru Mihai
If you need an int isn't better to use input() instead of raw_input() ? On Tue, Aug 23, 2011 at 10:00 PM, Adrián Monkas wrote: > Hi. > I`ve been trying to copy a long text from one file to another but it always > copied me just a small part. > I would be glad if you can help me or explain which i

Re: reading and writing files

2011-08-23 Thread Chris Rebert
On Tue, Aug 23, 2011 at 9:05 PM, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, Adrián Monkas wrote: >>             print "Abro Archivo Origen" >>             archivo=open("D:\Boot.txt","r") > Your filenames are incorrect, since you use the backslash without escaping > it.  So the source file ha

Re: reading and writing files

2011-08-23 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Adrián Monkas wrote: Hi. I`ve been trying to copy a long text from one file to another but it always copied me just a small part. I would be glad if you can help me or explain which is my error. Thanks ---

Re: Reading (and writing?) audio file tags

2007-05-25 Thread Jarek Zgoda
Paul Moore napisał(a): >> Anyway, what you want is Mutagen. It handles both Flac and Mp3 tags, as well >> as many others:http://www.sacredchao.net/quodlibet/wiki/Development/Mutagen > > Excellent! The web page you mentioned gave "access denied", but I got > to it via Google's cache, and the downl

Re: Reading (and writing?) audio file tags

2007-05-24 Thread Paul Moore
On 24 May, 17:22, darren kirby <[EMAIL PROTECTED]> wrote: > quoth the Paul Moore: > > > I'd like to write some scripts to analyze and manipulate my music > > files. The files themselves are in MP3 and FLAC format (mostly MP3, > > but FLAC where I ripped original CDs and wanted a lossless format). >

Re: Reading (and writing?) audio file tags

2007-05-24 Thread darren kirby
quoth the Paul Moore: > I'd like to write some scripts to analyze and manipulate my music > files. The files themselves are in MP3 and FLAC format (mostly MP3, > but FLAC where I ripped original CDs and wanted a lossless format). > I've no idea what form of tags are used in the files (ID3v1, ID3v2,

Re: Reading and Writing

2004-12-24 Thread Mike Meyer
Sir Galahad the chaste <[EMAIL PROTECTED]> writes: > Hi, > > [EMAIL PROTECTED] wrote: >> How should I: Open a Text file, read from it, modify it, print to >> another .txt? >> For instance: Read a string, sort it, write the sorted string. > > What do you mean by "sorting"? If you want to sort the l

Re: Reading and Writing

2004-12-23 Thread Novitiate
-Galahad, Thank you very much. I will give it a shot and see if I can make it hapen. I think this will help a lot. I was just trying to implement a simple sorting algorithm that I knew from C++, for practice but I couldn't figure the mechanics of Python. Thanks again, Novitiate -- http://mai

Re: Reading and Writing

2004-12-23 Thread Novitiate
-Galahad, Thank you very much. I will give it a shot and see if I can make it hapen. I think this will help a lot. I was just trying to implement a simple sorting algorithm that I knew from C++, for practice but I couldn't figure the mechanics of Python. Thanks again, Novitiate -- http://mai

Re: Reading and Writing

2004-12-23 Thread Sir Galahad the chaste
Hi, [EMAIL PROTECTED] wrote: How should I: Open a Text file, read from it, modify it, print to another .txt? For instance: Read a string, sort it, write the sorted string. What do you mean by "sorting"? If you want to sort the lines contained in a file, you could do something like this. $ cat in.