This script was developed to take a column of a CSV and render it as JSON. Because it was meant for U.S. choropleth maps, it makes a few assumptions about the input CSV's structure--specifically that it has at least three columns:
-
FIPS
contains a five-digit FIPS 6-4 county code for rows with county-level data. For rows with state-level data, a two-digit FIPS 5-2 state code is used by convention but is ignored. -
Name
contains the common English name for the area. This is used for rows with state-level data and ignored for rows with county-level data. -
Any other column is treated as a data column that can be rendered as JSON.
The output JSON contains the original CSV's string representation of data
values and therefore probably needs some sort of regex-based find-and-replace
used on it to make it more usable. The keys are FIPS codes for counties (as
found in the FIPS
column) and state names (as found in the Name
column) for
states.