Skip to content

Instantly share code, notes, and snippets.

Created October 9, 2022 18:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
ISP csv to jsonl script
import argparse
import pandas as pd
import json
def main():
parser = argparse.ArgumentParser(description="List the content of a folder")
help="path to the input csv",
args = parser.parse_args()
path_csv = args.path
print(f"CSV file used for the expor: {path_csv}")
path_jsonl = path_csv.replace(".csv", ".jsonl")
df = pd.read_csv(path_csv)
df.classes = df.classes.apply(lambda x: json.loads(x.replace("'","\""))) # create list from string list
with open(path_jsonl, "w") as f:
f.write(df.to_json(orient="records", lines=True))
print(f"CSV file exported to: {path_jsonl}")
if __name__ == "__main__":
Copy link

MicPie commented Oct 9, 2022

Run with python yourdata.csv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment