Skip to content

Instantly share code, notes, and snippets.

View Talgatovich's full-sized avatar

Раиль Ибятов Talgatovich

View GitHub Profile
@katylava
katylava / copy-to-psql.py
Created December 8, 2010 17:42
script to load csv file into new postgres table
#!/usr/bin/env python
import re
from subprocess import call
def load_csv_psql(db, infile, table, tmpdir='/tmp'):
tmpfile = '%s/%s' % (tmpdir, infile)
call(['cp', infile, tmpfile])
columns = map(variablize, file(infile).readline().split(','))