目前,我正在尝试从csv文件导入由以下python脚本创建的json文件
import csv, json
csvFilePath ='USvideos.csv'
jsonFilePath = 'USvideos.json'
data = {}
with open(csvFilePath, encoding = 'utf8') as csvFile:
csvReader = csv.DictReader(csvFile)
for csvRow in csvReader:
video_id = csvRow['video_id']
data[video_id] = csvRow
with open(jsonFilePath, 'w') as jsonFile:
jsonFile.write(json.dumps(data, indent=4))
问题语句问题是,我需要通过修改python脚本来获得一个不带括号部分的json文件
("2kyS6SvSYSE": ) {
"video_id": "2kyS6SvSYSE",
"trending_date": "17.20.11",
"title": "WE WANT TO TALK ABOUT OUR MARRIAGE"
},
("1ZAPwfrtAFY":) {
"video_id": "1ZAPwfrtAFY",
"trending_date": "17.20.11"
}
解决的目的 我需要解决这个问题,因为我想在MongoDB中适当地导入数据
猜测您需要的输出JSON格式,但是您能尝试一下吗
相关问题 更多 >
编程相关推荐