from typing import List import pandas as pd # from celery_tasks import app # @app.task def parse_index_table(tables_list: List[dict]): for table_dict in tables_list: if (table_dict.get('table_name') == '索引表') or ('索引表' in table_dict.get('table')[0][0]): # return True table = table_dict.get('table') df = pd.DataFrame(table[2:], columns=table[1]) print(df[['条款号', '评分因素', '页码']]) # return False if __name__ == '__main__': import json from glob import glob for file in glob('D:\\desktop\\三峡水利\\data\\projects\\*\\投标\\*\\*table.json'): # with open('D:\\desktop\\三峡水利\\data\\projects\\三峡左岸及地下电站地坪整治\\投标\\湖北建新建设工程有限公司_T221100130348%2F01整本文件\\投标文件-修改版9-5-1-1-table.json', 'r', encoding='utf-8') as fp: print(file) with open(file, 'r', encoding='utf-8') as fp: tables_list = json.load(fp) print(parse_index_table(tables_list=tables_list))