python - Opening a file and selecting specific column in file -


hello new python , need help

i have set of data below large values column 1 , xx.x column 2 19600110 28.6 19600111 28.9 19600112 29.2 19600113 28.6 19600114 28.6 19600115 28.4 19600116 28.6 19600117 28.6

stored station.txt

i trying python present first column of data (19600115 etc) labelled dates.i opened file , using loop try open 1st column. not sure going wrong appreciated

def load_dates(stations):
"""loads station dates , excludes station temperature data"""

f = open(stations[0] + '.txt', 'r') #create loop , open first column of data dates #close file , return body of dates dates = [] line in f:     dates.append(lines(7)) f.close()  return dates 

dates = [] line in f:     dataitem = line.split() #split while space default, list     date = dataitem[0] #index 0 first element of dataitem list     dates.append(date) f.close() 

in summary, need split line string first, choose date


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -