-4

right now I am trying to write a code that takes the data from a URL file to compute average temperatures. The file reads in properly (I did a print statement for "d" and everything is there), but after that everything seems to stop working.

The file has 4 columns (in this order): day, month, year, and temperature. Since I want to compute the average temperatures I only need that last column but I was trying to define all the columns first since I need to be able to find the average temperature for each year!

I really hope you can help, I have worked on this for hours and hours and have gotten no where.

Here's the beginning of my current code....

local_file='str(station)'
infile = open(local_file, 'r')
d=infile.readlines()
data = {}
data['data'] = {}
#defines each column with an actual variable name
for line in infile:
  columns = line.split()
  print columns
  month = int(columns[0])
  day = int(columns[1])
  year = int(columns[2])

================================================

Thanks in advance for any help at all. I really appreciate any advice!

1 Answers1

1

Remove the line d=infile.readlines() or use d into for-loop instead infile

pbacterio
  • 878
  • 4
  • 10