If no path is provided, the method returns the JSON string as output and returns. The Dataframe.tojson (path, orient) method of the Pandas module, takes DataFrame and path as input and converts it into a JSON string, and saves it at the provided path. We have taken 850MB size CSV file and tried converting this to JSON format. So, here I did got my answer but instead of printing it once, It is printing 7 times. Convert CSV File to JSON File in Python Using the Dataframe.tojson () Method in Python. We have tried testing both the methods of converting CSV to JSON in Python using both the listed methods. Output userID,Is salary credited before 5th,Avg Salary of last 3 months,Avg Salary of last 6 months,Avg Balance before salary of last 3 months,Avg Balance before salary of last 6 monthsĦ79d3bad-155e-4b39-9ff7-7d564f408942,Yes,15453.33,15290.5,113.15,105.22 Following is my json file input Ĭode with open('/Users/vrindabv/Documents/PycharmProjects/BankStatementEngine/test.json', "r") as f:į = csv.writer(open("/Users/vrindabv/Documents/PycharmProjects/BankStatementEngine/test.csv", "w"))į.writerow()į.writerow(, x,
0 Comments
Leave a Reply. |