Re: delete first line in a file



this helps me!

thank you very much!!!!!

greetings, juergen



JH> 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>

JH> that documentation i have already read, but it wouldn`t help me for my

JH> problem!

JH> i know, how i can read the first line an print them on the screen!

JH> but...how can i say python, delete the first line?!

JH> thats my problem!

as Fredrik told you, you can not delete the first line directly!!!

JH> in the entry of my posting i wrote, that i am a newbie and so please

JH> understand me, that i ask so questions?! :-)

We are trying to understand that, but it is expected some effort on

your side as well :)

You didn't read the documentation properly!

try to experiment with the code by yourself as well!

Try:

1) open your file

2) use readlines() method

which returns the list of ALL rows from the file and store them to some
variable.

it can be done for example like:

all_lines = f.readlines()

(if you do not know, what the list is, start here:

http://docs.python.org/tut/node5.html#SECTION005140000000000000000)

4) save the list members without its first member to the file

for example:

for line in all_lines[1:]:

f.write(line)

5) close the file



Good luck

Petr Jakes











JH> thanks for your help!



.



Relevant Pages

  • Re: Is re.findall guaranteed to be "in order?"
    ... Fredrik Lundh wrote: ... (the documentation is a bit vague, so if you have the time, please add a ... request for clarification to the bug tracker) ...
    (comp.lang.python)
  • Re: Inheritance from builtin list and override of methods.
    ... On Monday 27 November 2006 11:50, Fredrik Lundh wrote: ... In this documentation page it also says: ... This, and other statements, are only roughly true for instances of new-style ... So which statements are actually true for new style classes? ...
    (comp.lang.python)
  • Re: python and macros (again) [Was: python3: where keyword]
    ... Fredrik Lundh wrote: ... it seems that Guido is wrong then. ... "The documentation clearly states that not all statements can ... Python Web Programming http://pydish.holdenweb.com/ ...
    (comp.lang.python)