offline$ cd data/
offline/data$
psql ml_latest_small -U postgres -c "\copy (SELECT '00000000-0000-0000-0000-' || lpad(cast(user_id AS TEXT), 12, '0') AS id, user_name || '@rsl.org' AS email FROM users ORDER BY id ASC) to 'users_.csv' with delimiter E'\t' csv header encoding 'UTF8'"
psql ml_latest_small -U postgres -c "\copy (SELECT movie_id AS id, title, year, imdb_id, tmdb_id FROM movies NATURAL JOIN links ORDER BY movie_id ASC) to 'movies.csv' with delimiter E'\t' csv header encoding 'UTF8'"
psql ml_latest_small -U postgres -c "\copy (SELECT genre_id AS id, genre_name AS name FROM genres ORDER BY genre_id ASC) to 'genres.csv' with delimiter E'\t' csv header encoding 'UTF8'"
psql ml_latest_small -U postgres -c "\copy (SELECT movie_id, genre_id FROM movies_genres ORDER BY movie_id ASC, genre_id ASC) to 'movies_genres.csv' with delimiter E'\t' csv header encoding 'UTF8'"
psql ml_latest_small -U postgres -c "\copy (SELECT '00000000-0000-0000-0000-' || lpad(cast(user_id AS TEXT), 12, '0') || '_' || lpad(cast(movie_id AS TEXT), 6, '0') AS id, '00000000-0000-0000-0000-' || lpad(cast(user_id AS TEXT), 12, '0') AS user_id, movie_id, rating, rated_at FROM ratings ORDER BY user_id ASC, movie_id ASC) to 'ratings.csv' with delimiter E'\t' csv header encoding 'UTF8'"
psql ml_latest_small -U postgres -c "\copy (SELECT '00000000-0000-0000-0000-' || lpad(cast(user_id AS TEXT), 12, '0') || '_' || lpad(cast(movie_id AS TEXT), 6, '0') AS id, '00000000-0000-0000-0000-' || lpad(cast(user_id AS TEXT), 12, '0') AS user_id, movie_id, tag, tagged_at FROM tags ORDER BY user_id ASC, movie_id ASC) to 'tags.csv' with delimiter E'\t' csv header encoding 'UTF8'"