Converting JSON to CSV with 1 Line of Code
· 1 min read
Ever had a large JSON
file that you needed to convert to CSV
? Snap.
My initial thought was to write an Awk
script. Thankfully, years of being constantly pleasantly surprised by Python nudged me to take a look. Behold! (Not quite 1 line of code, but 1 line to invoke a Pandas DataFrame method.)
import pandas as pd
df = pd.read_json('/my/JSON/file')
# convert to CSV
df.to_csv()
O Python! Let me count the ways…