code to export pg query, heroku pg:psql and then query - \copy (SELECT id, boss_code FROM spree_products) TO id_boss.csv CSV DELIMITER ',' and then \q to exit