Skip to content

Instantly share code, notes, and snippets.

@mapcentia
Last active August 29, 2015 14:08
Show Gist options
  • Save mapcentia/da750c3209022dab0770 to your computer and use it in GitHub Desktop.
Save mapcentia/da750c3209022dab0770 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys, csv
args =sys.argv
filesource = args[1]
with open(filesource, 'rb') as f:
reader = csv.reader(f, delimiter=';', quotechar='"')
for row in reader:
statement = "INSERT INTO " + args[2] + " " + \
"(" +\
"id," + \
"value," + \
"sensor_id," + \
"location" +\
") " + \
"VALUES (%s,%s,%s,ST_geomfromtext('POINT(%s %s)',4326));" % (row[3],row[6],"1",row[5],row[4])
print statement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment