Using app script to pass input from .csv file in Google Storage to Prediction API

1.1k Views Asked by At

how can I use app script to pass input from .csv file in Google Storage so that I can make bulk predictions (>10,000) with the Prediction API? I have created and trained my prediction model using the Google APIs Explorer. The idea

  1. Upload input .csv file to Google Storage. It contains many input rows - I wish to make one prediction for each row.
  2. Open a Google Spreadsheet which will store our predictions.
  3. Load the .csv file from Google Storage. Fetch one row and set it as csv instance. Call Prediction.
  4. Store the prediction in the first column of the spreadsheet. Write selective columns (features) from the input row into the spreadsheet to give the predicted value some context.
  5. Loop through all rows in the .csv file and make prediction for each row.

How do I perform Step 2 onwards in Google App Script? Are there existing libraries in app script to manipulate .csv files?

The doc is rather sketchy in this area, but the product is intriguing and I wish more examples can be given.

1

There are 1 best solutions below

2
On

Google Spreadsheets are able to import CSV files. This means you can import your CSV file to a Spreadsheet and after open this Spreadsheet from a script and manipulate data as you wish. If you upload the CSV file programmatically, then there is ability not upload the CSV file as a file but upload data directly to a Spreadsheet using the Google Spreadsheets Data API