Skip to content

Instantly share code, notes, and snippets.

@amalgjose
Last active February 5, 2023 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amalgjose/5b8fd9ed08b7957e15973fe4b11805cb to your computer and use it in GitHub Desktop.
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
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