Skip to content

Instantly share code, notes, and snippets.

@stevevance
Last active August 29, 2015 14:01
Show Gist options
  • Save stevevance/42d92e07ba45065c6a5b to your computer and use it in GitHub Desktop.
Save stevevance/42d92e07ba45065c6a5b to your computer and use it in GitHub Desktop.
Changing date formats from Socrata for PostgreSQL
PostgreSQL prefers dates in YYYY-MM-DD format but Socrata-hosted datasets may instead use MM/DD/YYYY. You can easily use OpenRefine to change between date formats.
* Click on the drop down arrow next to the date column that needs to change.
* Click Edit Cells>Transform
* In the Expression box, input smartSplit(value,"/")[2]+"-"+smartSplit(value,"/")[0]+"-"+smartSplit(value,"/")[1]
Then you can copy the CSV file into PostgreSQL with the COPY command:
COPY table_name FROM '/path/to/file.csv' WITH CSV HEADER DELIMITER AS ',';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment