forked from USEPA/mywaterway
-
Notifications
You must be signed in to change notification settings - Fork 0
Convert introText Exel doc to js
Caleb Schwind edited this page Jul 13, 2020
·
1 revision
- Delete all columns to the right of the "Weblink" column, these extra columns will show up in the output if you don't delete them.
- Delete all extra rows at the bottom of the spreadsheet, these extra rows will show up in the output if you don't delete them.
- Verify that all territories have the correct 2 character state code (i.e. AS = American Somoa, GU = Guam, PR = Puerto Rico, MP = Northern Mariana Islands ,VI = US Virgin Islands).
- Save the spreadsheet as a csv.
- Go to convertcsv.com
- Copy/paste the contents of the csv file into the box in Step 1.
- Expand Step 2
- Uncheck the "First row is column names" option
- Put 3 in for the "Skip # of Lines" option
- Expand Step 4
- Enter the following into "Top"
export default {lb}{br}
- Copy and paste the following into "Repeating Section for each line of CSV"
{f1}: {lb} region: {(f2)==""? "null" : f2}, intro: {(f3)==""? "null" : '"' + f3 + '"'}, url: "{f13}", metrics: [ {lb} value: {(f5)==""? "null" : '"' + f5 + '"'}, label: {(f4)==""? "null" : '"' + f4 + '"'}, unit: {(f6)==""? "null" : '"' + f6 + '"'}, {rb}, {lb} value: {(f8)==""? "null" : '"' + f8 + '"'}, label: {(f7)==""? "null" : '"' + f7 + '"'}, unit: {(f9)==""? "null" : '"' + f9 + '"'}, {rb}, {lb} value: {(f11)==""? "null" : '"' + f11 + '"'}, label: {(f10)==""? "null" : '"' + f10 + '"'}, unit: {(f12)==""? "null" : '"' + f12 + '"'}, {rb}, ], {rb}
- Enter the following into "Bottom"
{br}{rb};
- Click the "Convert CSV to JSON via Template" button
- Copy and past the contents of "Result Data" into introText.js
- Scan through the file and fix any of the following
- Comment out the contents of metrics for any items that have null values for everything in the metrics array.
- Remove any escape characters or \n
- Remove any leading or trailing spaces
- Check the changes and test.