把json文件转换成excel格式文件

自己没写一行代码,用通义千问生成的python程序搞定的,python我也不熟悉,只是helloworld水平。

import pandas as pd

import json

import argparse

def json_to_excel(input_json, output_excel):

读取json文件

with open(input_json, 'r') as f:

data = json.load(f)

将json数据转换为DataFrame

df = pd.DataFrame(data)

将DataFrame写入Excel文件

df.to_excel(output_excel, index=False)

if name == "main":

parser = argparse.ArgumentParser(description="Convert JSON file to Excel (xlsx) file.")

parser.add_argument("--input", "-i", required=True, help="Input JSON file name.")

parser.add_argument("--output", "-o", required=True, help="Output Excel (xlsx) file name.")

args = parser.parse_args()

json_to_excel(args.input, args.output)

1、新建一个py文件,复制粘贴过去。(电脑上要先安装python才能运行)

2、控制台给出输入和输出文件名(同目录)

python your_script_name.py -i input.json -o output.xlsx

3、如果提示缺失某个依赖,直接pip安装。

比如: import pandas as pd ModuleNotFoundError: No module named 'pandas'。没关系,在控制台终端,输入命令:pip install pandas

4、如果还有问题,跟GPT提问吧 ,它会告诉你的

相关推荐
AC赳赳老秦15 小时前
OpenClaw权限管理实操:团队共享Agent,设置操作权限,保障数据安全
服务器·开发语言·前端·javascript·excel·deepseek·openclaw
guslegend17 小时前
AI生图第3节:gpt-image-2的提示词反解析与Json结构化生图
人工智能·gpt·json
Teable任意门互动19 小时前
多维表格哪家最好用最容易上手?国产开源 Teable 测评
开发语言·数据库·开源·excel·飞书·开源软件
wtsolutions1 天前
Excel-to-JSON Local App - Secure Offline Excel to JSON Conversion
json·excel
Hello_Embed1 天前
嵌入式上位机开发入门(二十九):JsonRPC TCP Server
网络·单片机·网络协议·tcp/ip·json·嵌入式
七夜zippoe2 天前
DolphinDB数据导入导出:CSV、JSON、Parquet
物联网·json·csv·parquet·dolphindb
qq_452396232 天前
第七篇:《数据驱动测试:利用Excel/JSON/CSV管理测试数据》
json·excel
是吗乔治2 天前
vuetify实现excel表格粘贴效果
前端·vue.js·vue·excel
herinspace3 天前
如何解决管家婆辉煌零售POS中显示的原价和售价不一致?
网络·人工智能·学习·excel·语音识别·零售