Last active
December 28, 2015 10:58
-
-
Save gravesm/7489580 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
from __future__ import print_function | |
import fileinput | |
import json | |
from datetime import datetime | |
import time | |
from pymongo import MongoClient | |
def get_collection(conn=None): | |
client = MongoClient(conn) | |
return client.oastats.requests | |
def main(collection): | |
for line in fileinput.input(): | |
request = json.loads(line) | |
t = time.strptime(request['time'], "%Y-%m-%dT%H:%M:%S") | |
request['time'] = datetime.fromtimestamp(time.mktime(t)) | |
collection.insert(request) | |
if __name__ == '__main__': | |
collection = get_collection() | |
main(collection) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment