Working with Google Sheets
You can read/write data from/to Google Sheets using your favorite modeling language!
Supported languages and solving methods
Google Sheets integration is available for all of our paying users.
However, it is required that the language/solving method adopted by the user
supports either
- NEOS — Not supported: unfortunately, NEOS does not accept
.csv or.xlsx files. - GLPSOL — Supported: users can read and write
.csv files. -
Opt-server — Depends on the language being used:
- AMPL — Supported: users can read and write
.csv and.xlsx files. - GAMS — Supported: users can read and write
.csv and.xlsx files. - MOSEL — Supported: users can read and write
.csv and.xlsx files. - OPL — Partial support: it is technically possible to read
.csv files, but not easily.
- AMPL — Supported: users can read and write
How it works
The integration between PIFOP and Google Sheets works through the syncronization between a Google Sheets file and a PIFOP's copy of that file.
When you import a Google Sheets into a PIFOP project, you create a file in your project that is linked to the Google Sheets file. Whenever you read some data from that PIFOP file, you are essentially reading the data from its associated Google Sheets file, and whenever you write some data to that PIFOP file, you are essentially writing the data to its associated Google Sheets file.
A PIFOP's copy of a Google Sheets file can be in one of two formats: CSV — extension
Enable Google Sheets integration
After upgrading your account, go to Account > Integrations and click on the Google Drive button. Follow the steps to give PIFOP permission to read and write files in your Google Drive.
Import or create a Google Sheet
STEP 1. Open or create a PIFOP project.
STEP 2. In the left menu, click on to Import or Create a spreadsheet
STEP 3. Name PIFOP's copy of the Google Sheet according to the type of file data you want to work with:
-
.csv — Give it the same name of the worksheet that you want to import, adding the extension.csv . The name of the Google Sheet worksheet itself does not need to end with.csv , only PIFOP's copy of it.A Google Sheet file can contain multiple worksheets, but a .csv file can only reference a single worksheet. PIFOP uses the file name to detect which worksheet the file should be linked to. If you want to import multiple worksheets within a Google Sheets file, repeat the two previous steps for each worksheet. -
.xlsx — Give it any name ending with.xlsx .
Read and write Google Sheets as .csv
See below how you can read/write the above worksheets in different languages/solvers, assuming that you have already imported them into your PIFOP project.
AMPL — official docs
Read:GAMS — official docs
Read:GMPL (GLPSOL) — official docs
Read:Read and write Google Sheets as .xlsx
See below how you can read/write the above worksheets in different languages/solvers, assuming that you have already imported them into your PIFOP project.