how to convert json to csv in python

后端 未结 4 836
时光取名叫无心
时光取名叫无心 2020-12-19 22:27

Following is my json file input

{\"userID\": \"679d3bad-155e-4b39-9ff7-7d564f408942\", \"Is salary credited before 5th\": \"Yes\", \"Avg Salary of last 3 mon         


        
4条回答
  •  伪装坚强ぢ
    2020-12-19 23:19

    You can also use pandas to handle dataframe,

    dct = {"userID": "679d3bad-155e-4b39-9ff7-7d564f408942", "Is salary credited before 5th": "Yes", "Avg Salary of last 3 months": 15453.33,
           "Avg Salary of last 6 months": 15290.5, "Avg Balance before salary of last 3 months": 113.15, "Avg Balance before salary of last 6 months": 105.22}
    
    import pandas as pd
    
    df = pd.DataFrame.from_records(dct, index=[0])
    
    df.to_csv('outputfile.csv')
    

提交回复
热议问题