Re[2]: delete first line in a file



JH> this helps me!

JH> thank you very much!!!!!

JH> greetings, juergen
I am happy to see my postings (which I sent by accident to you only, not to
the list, see below) helped. But....:
Its a pity we can not see your solution (your code) here :(
It helps to others as well to see, how to solve some "problems"

Petr Jakes
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!
PJ> 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?! :-)
PJ> We are trying to understand that, but it is expected some effort on
PJ> your side as well :)
PJ> You didn't read the documentation properly!
PJ> try to experiment with the code by yourself as well!

PJ> Try:

PJ> 1) open your file
PJ> 2) use readlines() method
PJ> which returns the list of ALL rows from the file and store them to some
PJ> variable.
PJ> it can be done for example like:

PJ> all_lines = f.readlines()

PJ> (if you do not know, what the list is, start here:
PJ> http://docs.python.org/tut/node5.html#SECTION005140000000000000000)

PJ> 4) save the list members without its first member to the file
PJ> for example:

PJ> for line in all_lines[1:]:
PJ> f.write(line)

PJ> 5) close the file

JH> Good luck
JH> Petr Jakes











JH>> thanks for your help!




.



Relevant Pages

  • Re: Is there an email group which avoids offensive rubbish?
    ... email list, post all postings to the list members and ALSO post them to the ng, so that further discussion can continue on the ng, but none of it gets back to the list. ... A is note automatically added to such postings saying that if you want to become a member of the list, then you can, but you'll have to behave yourself or you'll be thrown out. ... Stephen Kellett ...
    (uk.music.folk)
  • RE: Barb How do I get back to you...
    ... To continue on the same thread, simply locate the thread in the news reader, ... You can click any entry in the thread to reply to but if your ... confusing to others who read the postings. ... I believe the last posting that Barb made gave you was a revision to the ...
    (microsoft.public.excel.programming)
  • RE: How to search for records using a form
    ... P.S. sorry about all the postings - MS kept giving me errors. ... > than one entry so you know to change all of them. ... It pulls up a blank form, you enter data, and it finds the ...
    (microsoft.public.access.forms)
  • Re: Cannot read own postings since a while
    ... read on webbased newssites. ... I can read my older postings though. ... You don't have an entry in the Blocked Senders List which matches your ... Freu"Whyever you're not asking in the german languaged OE6 newsgroup"di ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: 8 hours to Starfest...
    ... postings and if no one else has already done it, I'll send you the entry. ... Bloody nouveaux riches. ... Palooka :-) ...
    (rec.gambling.poker)