Skip to content

Commit

Permalink
Add a script that will create JSON files for each record
Browse files Browse the repository at this point in the history
Toward #1.
  • Loading branch information
waldoj committed Mar 11, 2018
1 parent 19fc2b5 commit e92b06d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
api/
18 changes: 18 additions & 0 deletions api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# The source CSV file.
SOURCE_DATA=united-states.csv

# Where we want our JSON files to go.
OUTPUT_DIR=./api

# Create the JSON directory.
mkdir -p "$OUTPUT_DIR"

# Iterate through each line in the CSV file.
while read -r p; do
FIPS_VALUE=$(echo "$p" | cut -d "," -f 1)
GNIS_VALUE=$(echo "$p" | cut -d "," -f 2)
OUTPUT_FILE="$OUTPUT_DIR"/"$FIPS_VALUE".json
echo "{\"fips\":\"$FIPS_VALUE\",\"gnis\":\"$GNIS_VALUE\"}" > "$OUTPUT_FILE"
done <$SOURCE_DATA

0 comments on commit e92b06d

Please sign in to comment.