Skip to content

Instantly share code, notes, and snippets.

@babadofar
Created February 4, 2015 11:49
Show Gist options
  • Save babadofar/da46298dc459448678e0 to your computer and use it in GitHub Desktop.
Save babadofar/da46298dc459448678e0 to your computer and use it in GitHub Desktop.
Vinmonopolet csv dump postgres import
-- data http://www.vinmonopolet.no/api/produkter
-- beskrivelse http://vertical.vinmonopolet.no/vmp/om-vinmonopolet/datadeling/_attachment/434521?_ts=1468fb68128
-- prepare the downloaded data by replacing Norwegian numeric separator , with . (using this regex:(\d),(\d) replace:\1.\2
-- In my csv file there was a lonely double quote, that had to be manually deleted
--DROP DATABASE "vinmonopolet";
CREATE DATABASE "vinmonopolet";
\connect vinmonopolet postgres
CREATE TABLE products (Datotid text, Varenummer text, Varenavn text, Volum decimal(6,1), Pris decimal(10,2), Literpris decimal(10,2), Varetype text,
Produktutvalg text, Butikkategori text, Fylde integer,
Friskhet integer, Garvestoffer integer, Bitterhet integer,
Sodme integer, Farge text, Lukt text, Smak text, Passertil01 text,
Passertil02 text, Passertil03 text, Land text, Distrikt text, Underdistrikt text, Argang integer, Rastoff text, Metode text, Alkohol decimal(5,2), Sukker text, Syre text, Lagringsgrad text, Produsent text, Grossist text, Distributor text, Emballasjetype text, Korktype text, Vareurl text) ;
COPY products
FROM 'f:/projects/blog/produkter20150202-002145-032.csv' DELIMITERS ';' HEADER CSV;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment