使用Python一口气将多个Json文件转换为多个CSV文件

问题描述 投票:0回答:1

我有大约3000个JSON文件,我想将其转换为相应的CSV文件。我正在使用Python中的熊猫进行转换。但是,它一次只能转换一个json文件,非常耗时。我想要一堆可以使用循环或其他方法使用Python将所有JSON文件转换为CSV的代码。

在下面的代码方法中,这些位置是我保存JSON文件并编写转换后的CSV文件的位置。

import pandas as pd

df = pd.read_json(r'D:/Meetup/DC_Events_Existing_Groups_Jan2019-March2020_inc_cancels/Events_by_Groups_67825_0.json')
export_csv = df.to_csv(r'D:/Meetup/Converted File/Events_by_Groups_67825_0.csv', index = None, header=True)

JSON数据看起来像:

[{"created":1529970910000,"duration":7200000,"id":"252139842","name":"Reston - Augst 12th - Abe Meetup - County Gov't Supervisor Office - 2:00PM","date_in_series_pattern":false,"status":"past","time":1534096800000,"local_date":"2018-08-12","local_time":"14:00","updated":1534106256000,"utc_offset":-14400000,"waitlist_count":0,"yes_rsvp_count":11,"venue":{"id":24368115,"name":"North County NEW BLDG  Gov't Supervisor's Office ","lat":38.963817596436,"lon":-77.360984802246,"repinned":false,"address_1":"1801 Cameron Glen Drive","city":"Reston","country":"us","localized_country_name":"USA","zip":"","state":"VA"},"group":{"created":1067987416000,"name":"Washington Abraham Hicks Meetup Group","id":1484,"join_mode":"open","lat":38.909999847412,"lon":-77.019996643066,"urlname":"Washington-Abraham-Hicks","who":"Leading Edge Creators","localized_location":"Washington, DC","state":"DC","country":"us","region":"en_US","timezone":"US\/Eastern"},"link":"https:\/\/www.meetup.com\/Washington-Abraham-Hicks\/events\/252139842\/"
python json pandas csv converters
1个回答
0
投票

感谢您的出色写作,对我有很大帮助。

© www.soinside.com 2019 - 2024. All rights reserved.