Created
August 1, 2017 20:54
-
-
Save rachelannelise/9b6b3f29d4e18ca45f161702f716b81f 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
from django.conf import settings | |
from django.db import IntegrityError | |
from account.models import ParselyAPIKey, Publisher | |
from django.core.exceptions import ObjectDoesNotExist | |
import csv | |
result = {} | |
with open('iheart_timezones.csv') as f: | |
reader = csv.reader(f) | |
for row in reader: | |
k, v = row | |
result[k] = v | |
for k,v in result.items(): | |
try: | |
apikey = ParselyAPIKey.objects.get(key=k) | |
apikey.timezone = v | |
apikey.save() | |
except ObjectDoesNotExist: | |
print "{} does not exist, skipping".format(k) | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment