Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions Scripts/Miscellaneous/JSONtoExcel/JSONtoEXCEL.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@

# Importing Pandas and json
import json
import pandas as pd
from pandas import DataFrame
import os
# Importing the data from a file using the load method
with open('./sampleData.json') as json_file:
data = json.load(json_file)
# Creating a dataframe
df = pd.DataFrame(data)
df.to_excel('./exported_json_data.xlsx')
def convert(inp_json_file:str) -> None:
"""Simple function to convert any .json file to a xlsx file of any name"""
with open(inp_json_file) as json_file:
data = json.load(json_file)
# Creating a dataframe
df = DataFrame(data)
out_xlsx_file = inp_json_file[:-4] + 'xlsx'
df.to_excel(out_xlsx_file)

if __name__ == "__main__":
convert(os.path.join((os.path.abspath(".")),"Python_and_the_web\Scripts\Miscellaneous\JSONtoExcel\sampleData.json"))