Skip to content

Instantly share code, notes, and snippets.

@kurozumi kurozumi/csv-to-json.py
Last active Apr 4, 2018

Embed
What would you like to do?
【Python】Pandasを使ってCSVをjsonに変換する方法
# coding: utf-8
import pandas as pd
df = pd.read_csv("sample.csv")
# ヘッダーがある場合
json = df.to_json(orient="records")
print(json)
# ヘッダーがない場合
json = df.to_json(orient="values")
print(json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.