|
@@ -0,0 +1,30 @@
|
|
|
+import pandas as pd
|
|
|
+
|
|
|
+def readXls(path):
|
|
|
+ # 读取xls文件
|
|
|
+ df = pd.read_excel(path)
|
|
|
+
|
|
|
+ # 分隔
|
|
|
+ num_columns = df.shape[1]
|
|
|
+ for col_index in range(num_columns):
|
|
|
+ column_data = df.iloc[:, col_index]
|
|
|
+ for value in column_data:
|
|
|
+ if "+" in str(value):
|
|
|
+ column_data=column_data.astype(str).str.split('+')
|
|
|
+ break
|
|
|
+ if "," in str(value):
|
|
|
+ column_data=column_data.astype(str).str.split(',')
|
|
|
+ break
|
|
|
+ if "/" in str(value):
|
|
|
+ column_data=column_data.astype(str).str.split('/')
|
|
|
+ break
|
|
|
+ df.iloc[:, col_index]=column_data
|
|
|
+
|
|
|
+ # 将DataFrame数据转换为字典列表
|
|
|
+ data_list = df.to_dict('records')
|
|
|
+ return data_list
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|