Skip to content

Instantly share code, notes, and snippets.

@kristiewirth
Created September 1, 2021 17:13
Show Gist options
  • Save kristiewirth/79b26505e9d0b79611dcdf308a57c83b to your computer and use it in GitHub Desktop.
Save kristiewirth/79b26505e9d0b79611dcdf308a57c83b to your computer and use it in GitHub Desktop.
Convert Alfred snippets export to CSV file
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