|
@@ -5,16 +5,26 @@ def readXls(path):
|
|
|
df = pd.read_excel(path)
|
|
|
|
|
|
# 分隔
|
|
|
- df.iloc[:, 0] = df.iloc[:, 0].astype(str).str.split('+')
|
|
|
- df.iloc[:, 2] = df.iloc[:, 2].astype(str).str.split('/')
|
|
|
- df.iloc[:, 4] = df.iloc[:, 4].astype(str).str.split('/')
|
|
|
- df.iloc[:, 6] = df.iloc[:, 6].astype(str).str.split('/')
|
|
|
+ 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|