Last active
February 5, 2023 02:47
-
-
Save amalgjose/5b8fd9ed08b7957e15973fe4b11805cb to your computer and use it in GitHub Desktop.
Program to convert csv file to JSON data using python pandas. This program assumes the csv file has a header. In case of missing header in the csv file, we have to pass it explicitly to the program
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 | |
# This program assumes the csv file has a header. | |
# In case of missing header in the csv file, we have to pass it explicitly to the program | |
csv_file = pd.DataFrame(pd.read_csv("data.csv", sep = ",", header = 0, 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