import xlrd
import pandas as pd
wb = xlrd.open_workbook("data.xlsx")
sh = wb.sheet_by_index(0)
# you have to name your columns by hand because not in the data (I put dummy value inside because lazy)
header = ['A'+str(i) for i in range(0,16)]
print(header)
data = {}
for row_num in range(sh.nrows):
row = sh.row_values(row_num)[0].split("\n") # The delimiter is '\n'
if not len(row) == len(header): #To not have the single column1 value in the data
print("Couldn't process: ", row)
continue
for index,column in enumerate(row):
data[header[index]] = data.get(header[index],[]) + [column]
df = pd.DataFrame(data)
好的,有分隔符,但在你的屏幕截图,他们是不可见的,我没有费心看excel文件,所以抱歉。你知道吗
所以分隔符是'\n',你可以用它分开。你知道吗
你必须自己为我输入的列名我把它命名为A0到A15,因为懒得从截图上写下来。你知道吗
相关问题 更多 >
编程相关推荐