Skip to content

Instantly share code, notes, and snippets.

@tlrobinson
Created April 11, 2016 05:42
Show Gist options
  • Save tlrobinson/ef32cfbade6fa6392685fcc2c116bede to your computer and use it in GitHub Desktop.
Save tlrobinson/ef32cfbade6fa6392685fcc2c116bede to your computer and use it in GitHub Desktop.
Import Moves app (https://www.moves-app.com/) data export files into PostgreSQL for analysis in Metabase (http://www.metabase.com/). Will need to change the paths to point to the downloaded and extracted CSVs.
CREATE TABLE activities (
"date" date,
"activity" varchar,
"group" varchar,
"start" timestamp,
"end" timestamp,
"duration" integer,
"distance" real,
"steps" integer,
"calories" integer
);
COPY activities (
"date",
"activity",
"group",
"start",
"end",
"duration",
"distance",
"steps",
"calories"
)
FROM 'moves_export/csv/full/activities.csv'
WITH CSV HEADER;
CREATE TABLE places (
"date" date,
"name" varchar,
"start" timestamp,
"end" timestamp,
"duration" integer,
"latitude" double precision,
"longitude" double precision,
"category" varchar,
"link" varchar
);
COPY places (
"date",
"name",
"start",
"end",
"duration",
"latitude",
"longitude",
"category",
"link"
)
FROM 'moves_export/csv/full/places.csv'
WITH CSV HEADER;
CREATE TABLE storyline (
"date" date,
"type" varchar,
"name" varchar,
"start" timestamp,
"end" timestamp,
"duration" integer
);
COPY storyline (
"date",
"type",
"name",
"start",
"end",
"duration"
)
FROM 'moves_export/csv/full/storyline.csv'
WITH CSV HEADER;
CREATE TABLE summary (
"date" date,
"activity" varchar,
"group" varchar,
"duration" integer,
"distance" real,
"steps" integer,
"calories" integer
);
COPY summary (
"date",
"activity",
"group",
"duration",
"distance",
"steps",
"calories"
)
FROM 'moves_export/csv/full/summary.csv'
WITH CSV HEADER;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment