When importing data into Postgres from a CSV, it's imperative that you do not try to alter the data - do that by explicitly transforming the data later on.
That means we need to import everything as text
, because that's the core string type in Postgres (as opposed to varchar
etc).
To create our schema and table:
create schema csvs;
create table csvs.master_plan(
start_time_utc text,
duration text,
date text,
team text,
spass_type text,
target text,
request_name text,
library_definition text,
title text,
description text
);
Copying data from a CSV into our new table:
copy csvs.master_plan
from '[Absolute path to]/csvs/master_plan.csv'
delimiter ',' header csv;