I want to read csv file and save it to variable in array using split delimiter in python, here the code:
data in csv :
2024-02-22 13:50:00 60 100
with open('sensor.csv') as csv_file_sensor:
csv_data_sensor = csv.reader(csv_file_sensor)
rows = list(csv_data_sensor)
print(rows[0])
for i in range(len(data)):
data[i]=rows[0].split(',')
print(data[i])
i got this error :
AttributeError: ‘list’ object has no attribute ‘split’
I want to save the csv data to 3 variable where data[0] = 2024-02-22 13:50:00, data[1]=60, and data[2]=100
New contributor
Kroysis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1