Simple data collector which uploads TSV formatted data files to Google Spreadsheet.
See Installation how to set up the collector.
In the next example, path/to/your_project is your own project that creates daily report data into data directory as data/YYYYMMDD.tsv.
Create .spreadsheet_report.yml in your project directory.
---
# spreadsheet_key will be found in the spreadsheet URL
spreadsheet_key: YOUR_GOOGLE_SPREADSHEET_KEY
sheet_name: YOUR_SHEET_NAME
# Data directory which directly includes TSV files.
# This is a relative path from your project root.
directory: data
# OPTIONAL
# The collector regards the first line of TSV file as column names.
# If your TSVs doesn't inclueds header, write column names as an array.
columns:
- col1
- col2
- col3Test:
$ bundle exec ./collect_data.rb -t path/to/your_projectIf everything is okey, execute without -t
$ bundle exec ./collect_data.rb path/to/your_projectConfirm TSV data is written in the last row of your sheet. (If not, check your sheet's first line matches column names in TSV in any order.)
You can add other targets in the same way.
- Create a project in Google Developers Console.
- Make Google Drive API available in API Section.
- Get OAuth key for an native application.
- Download application secret JSON file.
- Clone this repository.
cdandbundle install- Copy above JSON file as
.credentials.jsonin root directory. - Test Spreadsheet API conection
$ bundle exec ./collect_data.rb -t # -t means test-runShows up an URL to authorize API access from this script, open that in your browser. And enter your access code printed in the authorized page.
If authorization succeeded, Acquired token will be saved in .token.yml file.