我正在尝试读取 .csv 文件并收到此错误ValueError: could not convert string to float: '220'到目前为止,这是我的代码:import csvimport matplotlibimport osenvironment = []# Initialise data dirdir = os.getcwd()print(dir)parent = os.path.dirname(dir)parent = os.path.dirname(parent)parent = os.path.dirname(parent)basedir = os.path.dirname(parent)print(basedir)datadir = os.path.join(basedir, 'data')print(datadir)inputdatadir = os.path.join(datadir, 'input')print(inputdatadir)# Open file and read.file = os.path.join(inputdatadir, 'snowslope1.csv')f = open(file, newline='') reader = csv.reader(f, quoting=csv.QUOTE_NONNUMERIC)for row in reader: # A list of rows rowlist = [] for value in row: # A list of value rowlist.append(value) #print(value) environment.append(rowlist)f.close()# Plot environment.matplotlib.pyplot.imshow(environment)matplotlib.pyplot.show()有人可以帮忙解决这里出了什么问题吗?我不确定错误在哪里,因为它们似乎都只是这样的数字:我的文件 Snowslope1.csv 中的 220,221,222,223
添加回答
举报
0/150
提交
取消