Last active
August 29, 2015 14:01
-
-
Save stevevance/42d92e07ba45065c6a5b to your computer and use it in GitHub Desktop.
Changing date formats from Socrata for PostgreSQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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