Created
March 10, 2020 17:36
-
-
Save amalgjose/21db4a31a5ccee94e7bdc92204d2c0cb to your computer and use it in GitHub Desktop.
Python program to convert csv file to json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
# Since the headers are missing in the csv file, explicitly passing the field names in the program | |
csv_file = pd.DataFrame(pd.read_csv("data.csv", sep = ",", names = ["EmpID", "FirstName","LastName","Salary"], index_col = False)) | |
csv_file.to_json("data.json", orient = "records", date_format = "epoch", double_precision = 10, force_ascii = True, date_unit = "ms", default_handler = None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment