Conversion CSV to JSON - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Conversion CSV to JSON (/thread-31909.html) |
Conversion CSV to JSON - mati - Jan-09-2021 Hello Everyone, I'm new here. I'm looking for help in my code. I'm writting app to convert csv to json file and i did the conversion but final .json file looks like this: Quote:{Insted of this: Quote:[And my code to do conversion is: import tkinter as tk # Declaration of the library needed to create the graphical interface. from tkinter import filedialog from tkinter import messagebox import pandas as pd # Library declaration for data handling. def convertToJSON (): # Function that converts a .csv file to a .json file. global read_file export_file_path = filedialog.asksaveasfilename(defaultextension='.json') read_file.to_json (export_file_path)I was trying to rearrange the file after but it wasnt working. Can anyone help? Sorry for mistakes in this post, but its my first time RE: Conversion CSV to JSON - jefsummers - Jan-09-2021 With the limited code sample, not sure what your file looks like that you have read. It is also generally a bad idea to pass arguments to your function by global rather than as actual arguments. |