Skip to content

Instantly share code, notes, and snippets.

@jacobandresen
Created November 10, 2018 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobandresen/8e76cfa19a72a57ea409c54951870991 to your computer and use it in GitHub Desktop.
Save jacobandresen/8e76cfa19a72a57ea409c54951870991 to your computer and use it in GitHub Desktop.
politiets registerblade
from numpy import genfromtxt
from time import time
from datetime import datetime
from sqlalchemy import Column, Integer, Float, Date, String, VARCHAR
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import csv
import pandas
Base = declarative_base()
engine = create_engine('postgresql://jacobandresen@localhost/jacobandresen')
Base.metadata.create_all(engine)
print("importing data")
df = pandas.read_csv('data/rode.csv', error_bad_lines=False, low_memory=False)
df.to_sql(con=engine, name='rode', if_exists='replace')
print("read rode")
df = pandas.read_csv('data/hack4dk_police_person_w_occupations.csv', error_bad_lines=False, low_memory=False)
df.to_sql(con=engine, name='person_w_occupations', if_exists='replace')
print("read persons with occupations")
df = pandas.read_csv('data/hack4dk_police_person.csv', error_bad_lines=False, low_memory=False)
df.to_sql(con=engine, name='person', if_exists='replace')
print("read persons")
df = pandas.read_csv('data/hack4dk_police_address.csv', error_bad_lines=False, low_memory=False)
df.to_sql(con=engine, name='address', if_exists='replace')
print("read address")
df = pandas.read_csv('data/hack4dk_police_position.csv', error_bad_lines=False, low_memory=False)
df.to_sql(con=engine, name='position', if_exists='replace')
print("read position")
df = pandas.read_csv('data/hack4dk_police_relation.csv', error_bad_lines=False, low_memory=False)
df.to_sql(con=engine, name='relation', if_exists='replace')
print("read relation")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment