I have a .csv file with data constructed as [datetime, "(data1, data2)"]
in rows and I have managed to import the data into python as time
and temp
, the problem I am facing is how do I seperate the temp
string into two new_temp
columns in float format to use for plotting later on?
My code so far is:
import csv
import matplotlib.dates as dates
def getColumn(filename, column):
results = csv.reader(open('logfile.csv'), delimiter = ",")
return [result[column] for result in results]
time = getColumn("logfile.csv",0)
temp = getColumn("logfile.csv",1)
new_time = dates.datestr2num(time)
new_temp = [???]
When I print temp
I get ['(0.0, 0.0)', '(64.4164, 66.2503)', '(63.4768, 65.4108)', '(62.7148, 64.6278)', '(62.0408, 63.9625)', '(61.456, 63.2638)', '(61.0234, 62.837)', '(60.6823, 62.317)',...etc]
If anyone can help me then thanks in advance.