Skip to content

Instantly share code, notes, and snippets.

@bensonk
Created August 4, 2010 04:11
Show Gist options
  • Select an option

  • Save bensonk/507622 to your computer and use it in GitHub Desktop.

Select an option

Save bensonk/507622 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from pprint import pprint
query = "insert into observations(beach, month, date, year, observer, effortid, " + \
"brand, sex, age, behavior, time, photoname, comments) values('%s', '%s', " + \
"'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');"
rawdata = open("UgamakBrands2010.csv").readlines()
for line in [ line.strip().split(",") for line in rawdata[1:] ]:
print query % tuple(line)
for record in [ line.strip().split(',') for line in open('behavior_rank.csv').readlines()]:
print "insert into rankings (id, code, rank) values('%s', '%s', '%s');" % tuple(record)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment