Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Conversion CSV to JSON
#1
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:{
"asset_id": {
"0": 9,
"1": 10,
"2": 11,
"3": 12,
"4": 13,
"5": 14,
"6": 15,
Insted of this:
Quote:[
{"asset_id": 9,
"content_id": 0,
"os": [1.0,
1.0,
1.0,
2.0,
1.0,
1.0,
1.0,
1.0,
1.0,
3.0,
1.0,
2.0,
2.0,
1.0,
1.0,
1.0,
2.0,
1.0,
1.0,
2.0,
1.0,
1.0,
1.0,
1.0,
1.0,
2.0,
4.0,
2.0,
5.0,
2.0],
"path": "/BigBuckBunny_20_288_375.yuv"
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 Confused
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  .JSON conversion to .CSV or .xslx tccompton 4 3,897 Mar-23-2018, 03:51 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020