Created
September 25, 2013 18:35
-
-
Save jobelenus/6703996 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def main(): | |
smugmug = auth() | |
c = get_csv_reader() | |
headers = c.next() | |
del headers | |
counter = 0 | |
try: | |
for row in c: | |
print '.', | |
sys.stdout.flush() | |
init_record(row) | |
counter += 1 | |
if LIMIT and counter >= LIMIT: | |
break | |
except csv.Error as e: | |
print 'line %d: %s' % (c.line_num, e) | |
def get_album_title(row): | |
myid = int(row[POS_IMAGEID]) | |
title = None | |
if myid in IMAGE_IN_ALBUM.keys(): # am I already taken and in an album? | |
title = IMAGE_IN_ALBUM.get(myid) | |
else: # no, create my title | |
d = datetime.datetime.strptime(row[POS_CREATED], "%Y-%m-%d %H:%M:%S") | |
title = '%s (%s)' % ((str(row[POS_ALBUM]).strip()).title() or 'No Album Name Provided', d.strftime('%m/%d/%Y')) | |
IMAGE_IN_ALBUM[myid] = title | |
# set my references to my album name | |
refs = row[POS_GROUPING].split(' ') | |
for imageid in refs: | |
try: | |
imageid = int(imageid) | |
except: | |
pass | |
else: | |
if imageid not in IMAGE_IN_ALBUM.keys(): | |
IMAGE_IN_ALBUM[imageid] = title | |
return title | |
def init_record(row): | |
album_title = get_album_title(row) | |
ALBUM_DESC[album_title].append(row[POS_BYLINE]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment