diff --git a/docs/documentation/google-sheets-integration.md b/docs/documentation/google-sheets-integration.md new file mode 100644 index 0000000000..b5094aae14 --- /dev/null +++ b/docs/documentation/google-sheets-integration.md @@ -0,0 +1,69 @@ +# Getting data from Google Sheets + +**Advanced topic** + + +## How to use + +1. Follow step 1 & 2 of the following blog post: + +[https://medium.com/dilwoar-hussain/use-google-sheets-as-a-database-in-3-easy-steps-d0330a4bb3b3](https://medium.com/dilwoar-hussain/use-google-sheets-as-a-database-in-3-easy-steps-d0330a4bb3b3) + +2. In app/routes.js add: + +```javascript +const request=require('request') +const csv=require('csvtojson') + +``` + +```javascript + +router.get('/', function (req, res) { + var googleSheetsUrl = "https://docs.google.com/spreadsheets/d/e/2PACX-1vQ8oXOIqewtlNTyJvplT-QYSlX9UoB8XlV0gSTYBFHxtlF3HwdkVp-vJP7FIVgHhTheL8nKYxcaNu2t/pub?output=csv"; //this is the url for your CSV + + csv() + .fromStream(request.get(googleSheetsUrl)) + .then((googleSheetsData)=>{ + res.render('google-sheets-example', { googleSheetsData: googleSheetsData } ) + }); + +}) + +``` + +2. In the view add: + +```HTML +
OBJECTID | +Letter | +Polling_Di | +Ward | +Parliament | +ADDRESS | +County_Div | +ShapeSTArea | +
---|---|---|---|---|---|---|---|
{{ item["OBJECTID"] }} | +{{ item['Letter'] }} | +{{ item['Polling_Di'] }} | +{{ item['Ward'] }} | +{{ item['Parliament'] }} | +{{ item['ADDRESS'] }} | +{{ item['County_Div'] }} | +{{ item['ShapeSTArea'] }} | +
OBJECTID | +Letter | +Polling_Di | +Ward | +Parliament | +ADDRESS | +County_Div | +ShapeSTArea | +
---|---|---|---|---|---|---|---|
{{ item["OBJECTID"] }} | +{{ item['Letter'] }} | +{{ item['Polling_Di'] }} | +{{ item['Ward'] }} | +{{ item['Parliament'] }} | +{{ item['ADDRESS'] }} | +{{ item['County_Div'] }} | +{{ item['ShapeSTArea'] }} | +