Looping through File Question
vijayca
vijayeee at gmail.com
Wed Sep 5 07:15:44 EDT 2007
More information about the Python-list mailing list
Wed Sep 5 07:15:44 EDT 2007
- Previous message (by thread): Looping through File Question
- Next message (by thread): Looping through File Question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sep 5, 3:58 pm, planetmatt <planetm... at gmail.com> wrote: > I am a Python beginner. I am trying to loop through a CSV file which > I can do. What I want to change though is for the loop to start at > row 2 in the file thus excluding column headers. > > At present I am using this statement to initiate a loop though the > records: > > for line in f.readlines(): > > How do I start this at row 2? just use readline() method...this will move the file pointer to the next line.... example: fd=open("/tmp.txt","r") fd.readline() ##THIS MOVES THE FILE POINTER TO THE SECOND LINE now carry on with... for line in f.readlines(): #THIS WILL BEGIN WITH THE SECOND ROW AS THE FILE POINTER IS IN 2NDLINE ....
- Previous message (by thread): Looping through File Question
- Next message (by thread): Looping through File Question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list