Below is my JSON data that I am trying to convert into CSV.
{
"account_number": "xxxx",
"actual_reading_current": "14581",
"actual_reading_previous": "13925",
"address": "asdsa3"
}
My code thus far,
data_file=pd.read_json('E:\\invoice\\output\\response.json')
data_file.to_csv("try.csv",index=False)
One drawback is that it imports all the columns into csv, however, I want only the 1st and 2nd columns to be imported. Am I missing something here?
new code
data_file=pd.read_json('E:\\invoice\\output\\response.json')
data_file.to_csv("try.csv",index=False,columns=['account_number'])
in my output its showing multiple time but in my json its only 1 time
data_file.to_csv("try.csv", index=False, columns=['account_number', 'actual_reading_current'])read_jsonsupports importing individual columns. Have you tried deleting the columns you don't need?