report/tools/readxlsx.py

27 lines
732 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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)