我的目标是能够拥有任何excel电子表格(我将保存为.cvs),并在python中读取它。我知道如何提取数据,到目前为止我的代码就是这个......
file = input("insert csv file name to upload: ")
with open(file) as csvfile:
readCSV = csv.reader(csvfile, delimiter = ',')
# opens any csv file if input is correct with .csv extention
x = []
y = []
for row in readCSV:
x_values = row[0]
y_values = row[1]
x.append(x_values)
y.append(y_values)
X = x[1:] # gets rid of first line(title)
Y = y[1:]
X = [float(i) for i in X]
Y = [float(i) for i in Y]
如果数据采用第一行的好格式=" title"那么这在excel中很好。其余的都是价值观。但是,我如何过滤整个事物并忽略任何文本?
我尝试了.isdigit(),但是当引入浮动时我遇到了问题。