Created
September 1, 2021 17:13
-
-
Save kristiewirth/79b26505e9d0b79611dcdf308a57c83b to your computer and use it in GitHub Desktop.
Convert Alfred snippets export to CSV file
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 os | |
import pandas as pd | |
import json | |
# Update these for your use case | |
folder = 'FOLDER' | |
csv_filename = 'CSV_FILENAME' | |
concated_df = pd.DataFrame() | |
for filename in os.listdir(folder): | |
with open(f'{folder}/{filename}', 'r') as f: | |
try: | |
data = json.load(f) | |
except Exception: | |
pass | |
# Choose whether to transpose or not based on your JSON structure | |
temp_df = pd.DataFrame(data).transpose() | |
concated_df = pd.concat([concated_df, temp_df]) | |
concated_df.to_csv(csv_filename, index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment