I am very confuse to solve exercise 1 problem in week 4 assignment

here’s an error which i am struggling with:

TypeError Traceback (most recent call last)
Cell In[39], line 1
----> 1 TIME, SERIES = parse_data_from_file(DATA_PATH)

Cell In[38], line 14, in parse_data_from_file(filename)
3 “”“Parse data from csv file
4
5 Args:
(…)
9 (np.ndarray, np.ndarray): arrays of timestamps and values of the time series
10 “””
11 ### START CODE HERE
12 # Load the temperatures using np.loadtxt. Remember you want to skip the first
13 # row, since it’s headers. Make sure to use the correct column of the csv file.
—> 14 next(filename)
15 temperatures = np.loadtxt(float(filename[2]))
16 times = np.loadtxt(int(filename[0])) # Create the time steps.

TypeError: ‘str’ object is not an iterator

can anybody please help me to solve this problem ?

Hi @Shantanu7

This error tells you that you’re trying to use next() on a string object, but you must use it on an iterator. Here, filename is a string representing the path to your CSV file, but next(filename) assumes that filename is an iterator, which it is not.

Try opening the file first.

Hope it helps!

i share you screen short of my code in your dm

1 Like