delete first line in a file

Schüle Daniel uval at rz.uni-karlsruhe.de
Fri Jun 30 07:30:45 EDT 2006


Juergen Huber schrieb:
> Fredrik Lundh wrote:
>> Juergen Huber wrote:
>>
>>> ok...i thought as much, that i have to copy this file!
>>>
>>> how will i do that?!
>>> how will i fix this file => delete the first line?!
>>>
>>> with which commands could i do that?!
>> start here:
>>
>> http://docs.python.org/tut/node9.html#SECTION009200000000000000000
>>
>> </F>
> 
> that documentation i have already read, but it wouldn`t help me for my
> problem!
> i know, how i can read the first line an print them on the screen!
> but...how can i say python, delete the first line?!
> thats my problem!
> in the entry of my posting i wrote, that i am a newbie and so please
> understand me, that i ask so questions?! :-)
> 
> thanks for your help!


simple!

f = file("old.file")
ignore = f.readline()
file("new.file", "w+").write(f.read())

hth, Daniel




More information about the Python-list mailing list