import pandas as pd
import fire
import glob
import json

def text_to_csv(file_name):
    json_data = json.load(open(file_name, 'r'))
    df = pd.read_json(json_data)
    df.to_csv(file_name[:-3] + 'csv')

def main(dir):
    dir = dir.replace("\\", "/")
    file_paths = glob.glob(dir + "/*.txt")
    for fp in file_paths:
        print("file_path:" + fp)
        text_to_csv(fp)

if __name__ == ‘__main__’:
    fire.Fire()

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-26
  • 2021-10-01
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-29
  • 2022-12-23
  • 2021-07-05
  • 2021-06-24
  • 2021-08-13
  • 2022-01-10
  • 2022-12-23
相关资源
相似解决方案