report/tools/readxlsx.py

27 lines
732 B
Python
Raw Permalink Normal View History

2023-07-31 13:49:34 +08:00
import pandas as pd
import logging
import json
import sys
logger = logging.getLogger('main.sub')
def read(merge):
df = pd.read_excel(merge, None)
samplelist = df['sample_info']['sampleSn'].to_list()
if not samplelist:
logger.error('sample_info表为空读取excel信息失败')
raise UserWarning('sample_info表为空读取excel信息失败')
samdict = dict()
for name, contents in df.items():
if contents.empty:
samdict[name] = []
continue
contents.fillna('.', inplace=True)
samdict[name] = contents.to_dict('list')
return samdict
if __name__ == '__main__':
res = read(sys.argv[1])
print(res)