(Oct-04-2018, 07:56 PM)buran Wrote: One option is to use f.next() once, after opening the file.
next(f)
in Python 3 gonzo620 Wrote:i.e: can I print the element in the 3rd column directly(I know you can print lines but does it work with columns?)You don't have any column only lines,have to split the lines.
Then
line[2]
will get 3rd column,or fix your error in code over.for line in f: line = line.split('\t') #print(line) lat = line[0:2] print(lat)
Output:['Latitude', 'Longitude']
['82°30N', '62°20W']
['81°36N', '16°40W']
['79°59N', '85°56W']
['78°55N', '11°56E']
....
gonzo620 Wrote:Also, is there an easier way to do this other than lists?Working with data in this way is very inconvenient.
As @buran posted you should try to get data in a structure like eg a dictionary,
using csv module and and DictReader.