Skip to content

Instantly share code, notes, and snippets.

@glamp
Last active December 16, 2015 01:59
Show Gist options
  • Save glamp/5359279 to your computer and use it in GitHub Desktop.
Save glamp/5359279 to your computer and use it in GitHub Desktop.
--create a table to store the data
create table script_ferris_bueller
(
tag_type varchar,
speaker varchar,
line text,
line_begin int,
line_end int,
movie_name varchar
);
--upload the data
\COPY script_ferris_bueller FROM 'ferris_buellers_day_off.txt' CSV HEADER
--more explicit but useful if your columns aren't in order
\COPY script_ferris_bueller(tag_type,speaker,line,line_begin,line_end,movie_name)
FROM 'ferris_buellers_day_off.txt' CSV HEADER
--turn on extended display
\x
--take a peak at the data
select * from script_ferris_bueller order by random() limit 1;
---[ RECORD 1 ]-----------------------------------
--tag_type | dialogue
--speaker | FERRIS
--line | This is optomism. It's a common
-- | trait with my age group. Adults
-- | think it's cute, it's like a charming
-- | quick that infests youth. But it's
-- | a cool thing and I think, deep down,
-- | crusty old shits wish they had some.
-- | They wish they had her, too.
-- | (points to Sloane)
-- | Sorry. She's taken.
--line_begin | 2188
--line_end | 2197
--movie_name | ferris_bueller's_day_off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment