#!/usr/bin/env python # -*- encoding: utf-8 -*-import sys import json import os import pandas as pd import csv""" 获取文件名列表 """ def list_file_names(folder):exist_files = os.listdir(folder)file_list = []for f in exist_files:file_list.append(os.path.join(folder, f))return file_list""" 将指定目录下的json文件合并成一个csv文件 """ def merge_json_to_csv_file(folder, csv_file):file_list = list_file_names(folder)pdt = pd.DataFrame()for file in file_list:tb = pd.read_json(file)print(tb)pdt = pd.concat([pdt, tb], ignore_index=True)print(pdt)pdt.to_csv(csv_file, mode="a", encoding="utf_8_sig", header=1, index=0)merge_json_to_csv_file(r"E:\\文档\\major_score_list",r"E:\\文档\\major_score_list.csv", )