Last active
February 9, 2018 05:36
-
-
Save critmcdonald/41936712b1fd99795193b32baec51a83 to your computer and use it in GitHub Desktop.
Use this OpenRefine extract to add a geoid column to the census tract data for AP Redlining data. Edit line 127 and 135 to change "48" to your state FIPS number.
This file contains 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
[ | |
{ | |
"op": "core/column-addition", | |
"description": "Create column tract_fix at index 6 based on column census_tract using expression grel:value", | |
"engineConfig": { | |
"mode": "row-based", | |
"facets": [] | |
}, | |
"newColumnName": "tract_fix", | |
"columnInsertIndex": 6, | |
"baseColumnName": "census_tract", | |
"expression": "grel:value", | |
"onError": "set-to-blank" | |
}, | |
{ | |
"op": "core/row-star", | |
"description": "Star rows", | |
"engineConfig": { | |
"mode": "row-based", | |
"facets": [ | |
{ | |
"mode": "text", | |
"caseSensitive": false, | |
"query": ".", | |
"name": "tract_fix", | |
"type": "text", | |
"columnName": "tract_fix" | |
} | |
] | |
}, | |
"starred": true | |
}, | |
{ | |
"op": "core/text-transform", | |
"description": "Text transform on cells in column tract_fix using expression grel:value + \"00\"", | |
"engineConfig": { | |
"mode": "row-based", | |
"facets": [ | |
{ | |
"omitError": false, | |
"expression": "row.starred", | |
"selectBlank": false, | |
"selection": [ | |
{ | |
"v": { | |
"v": false, | |
"l": "false" | |
} | |
} | |
], | |
"selectError": false, | |
"invert": false, | |
"name": "Starred Rows", | |
"omitBlank": false, | |
"type": "list", | |
"columnName": "" | |
} | |
] | |
}, | |
"columnName": "tract_fix", | |
"expression": "grel:value + \"00\"", | |
"onError": "keep-original", | |
"repeat": false, | |
"repeatCount": 10 | |
}, | |
{ | |
"op": "core/text-transform", | |
"description": "Text transform on cells in column tract_fix using expression grel:replace(value,\".\",\"\")", | |
"engineConfig": { | |
"mode": "row-based", | |
"facets": [ | |
{ | |
"omitError": false, | |
"expression": "row.starred", | |
"selectBlank": false, | |
"selection": [ | |
{ | |
"v": { | |
"v": true, | |
"l": "true" | |
} | |
} | |
], | |
"selectError": false, | |
"invert": false, | |
"name": "Starred Rows", | |
"omitBlank": false, | |
"type": "list", | |
"columnName": "" | |
} | |
] | |
}, | |
"columnName": "tract_fix", | |
"expression": "grel:replace(value,\".\",\"\")", | |
"onError": "keep-original", | |
"repeat": false, | |
"repeatCount": 10 | |
}, | |
{ | |
"op": "core/text-transform", | |
"description": "Text transform on cells in column tract_fix using expression grel:\"000000\"[0,6-value.length()] + value", | |
"engineConfig": { | |
"mode": "row-based", | |
"facets": [] | |
}, | |
"columnName": "tract_fix", | |
"expression": "grel:\"000000\"[0,6-value.length()] + value", | |
"onError": "keep-original", | |
"repeat": false, | |
"repeatCount": 10 | |
}, | |
{ | |
"op": "core/column-addition", | |
"description": "Create column county_fix at index 4 based on column county_fips using expression grel:\"000\"[0,3-value.length()] + value", | |
"engineConfig": { | |
"mode": "row-based", | |
"facets": [] | |
}, | |
"newColumnName": "county_fix", | |
"columnInsertIndex": 4, | |
"baseColumnName": "county_fips", | |
"expression": "grel:\"000\"[0,3-value.length()] + value", | |
"onError": "set-to-blank" | |
}, | |
{ | |
"op": "core/column-addition", | |
"description": "Create column geoid at index 8 based on column tract_fix using expression grel:\"48\" + cells['county_fix'].value + cells['tract_fix'].value", | |
"engineConfig": { | |
"mode": "row-based", | |
"facets": [] | |
}, | |
"newColumnName": "geoid", | |
"columnInsertIndex": 8, | |
"baseColumnName": "tract_fix", | |
"expression": "grel:\"48\" + cells['county_fix'].value + cells['tract_fix'].value", | |
"onError": "set-to-blank" | |
}, | |
{ | |
"op": "core/column-removal", | |
"description": "Remove column county_fix", | |
"columnName": "county_fix" | |
}, | |
{ | |
"op": "core/column-removal", | |
"description": "Remove column tract_fix", | |
"columnName": "tract_fix" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment