load_csv.py
unknown
python
3 years ago
600 B
9
Indexable
import matplotlib.pyplot as plt
import csv
# Open the CSV file and read its contents into two lists
timestamps = []
values = []
with open('air_data.csv') as csvfile:
csvreader = csv.reader(csvfile)
for row in csvreader:
timestamps.append(row[0])
values.append(row[1])
# Convert the timestamps and values to numeric data types
timestamps = [float(ts) for ts in timestamps]
values = [float(val) for val in values]
# Plot the data using matplotlib
plt.plot(timestamps, values, color='red')
plt.xlabel('Timestamp')
plt.ylabel('Value')
plt.title('Data from CSV file')
plt.show()Editor is loading...