I'm a beginner and I am stuck at this practice exercise. I am not allowed to use any modules to solve this problem. I have a csv file with 10 rows representing a different house in each row and 20 columns representing days. For each day, it was recorded whether the temperature in a house fell below 15 deg C. There is no header to the file.
0,2,4,1,1,2,...
2,2,2,1,1,0,...
1,1,1,2,0,0,...
...
I need to perform some calculations such as the average number of times the temp fell below 15 deg C per house and per day. So I'm thinking I need a list of houses which contains all the rows as lists and a list of days which contains sorted values of the correlative columns like [[0,2,1,...],[2,2,1,...],...] to perform these calculations. So far I have tried
file = open("filename.csv")
days = []
for line in file:
line = line.strip()
data = line.split(",")
for x in range(0, len(data)):
days.append(int(data[x]))
print(days)
This is not giving me the list of days like I hoped for. I am getting one big list with all the data in it. What am I doing wrong?