Skip to content

Instantly share code, notes, and snippets.

@ohhdemgirls
Last active June 11, 2017 00:34
Show Gist options
  • Save ohhdemgirls/9306844 to your computer and use it in GitHub Desktop.
Save ohhdemgirls/9306844 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# ------------------------------
# Script to parse reddit json
# Usage $cat *.json | redditJSON.py
# ------------------------------
import sys
reload(sys)
sys.setdefaultencoding('utf8')
import json
import datetime
for line in iter(sys.stdin.readline, ""):
decode = json.loads(line)
time = datetime.datetime.fromtimestamp(int(decode['created_utc'])).strftime('%Y-%d-%m/%H:%M:%S')
#subreddit = decode['subreddit']
id = decode['id']
url = decode['url']
author = decode['author']
title = decode['title']
print time, id, url, author, title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment