I have two functions I have created as follows
def load_dates(stations):
f = open(stations[0] + '.txt', 'r')
dates = []
for line in f:
dates.append(line.split()[0])
f.close()
return dates
stations = load_stations("stations.txt")
dates = load_dates(stations)
and
def load_station_data(station):
f = open(stations[0] + '.txt', 'r')
temp = []
for line in f:
x = (line.split()[1])
x = x.strip()
temp.append(x)
f.close()
return temp
The first function retrieves dates from a list in a seperate file (hence openfile function) which can be seen to be the first column and the second retrieves the temperatures whilst eliminating the spaces. The second function however goes and gets the temperatures from a specific file (station).
Dates Temp
19600101 29.2
19600102 29.4
19600103 29.5
The question I have now is how I could make my new function display the list of data for temp inside a corresponding list for different station files
for example there is a list of temperatures that belong to every station(city). I know what I have to do is create an empty list keep iterating through the the stations using a for loop and then add what i iterated throughout the empty lists using the append function. I am new to python and so am struggling with the part said above