Extract csv from google sheet to dropbox - csv

Is there a way to extract data from google sheet's work sheet, to a specific dropbox folder, in CSV format? Additionally, previously created CSV file must be re-written / replaced whenever new data is added to work sheet. Basically, I need a one-way sync from sheet to a CSV file in a dropbox folder.

Related

Inserting multiple CSVs from to one Google sheet

I have a recurring process where I have a zip file with 4 CSVs that I want to add to a google sheet (new or existing). Is there a way to automate this?
It's just a one time import, not live data.
To do this manually, use File > Import four times and choose the Append to current sheet option each time.
To automate this with a Google Sheet formula, the data must be in .csv files rather than a .zip file, and those files must be reachable through the web without authentication.
If you can automate the unzip process and place the files in the cloud someplace, say a Dropbox folder, so that the file URLs are always the same, you can use importdata() like this to concatenate the files:
={
importdata("...url1.csv");
importdata("...url2.csv");
importdata("...url3.csv");
importdata("...url3.csv")
}
To automate this with Apps Script, use an installable trigger to run a function that uses UrlFetchApp, Utilities.gunzip and Utilities.parseCsv() to get the data, Array.concat() to merge the files, and Range.setValues() to write the results in the spreadsheet.
To reference a cell or range of cells in another worksheet in the same workbook, put the worksheet name followed by an exclamation mark (!) before the cell address.
In other words, in an Excel reference to another worksheet, you use the following format:
Reference to an individual cell:
Sheet_name!Cell_address
For example, to refer to cell A1 in Sheet2, you type Sheet2!A1.
Reference to a range of cells:
Sheet_name!First_cell:Last_cell
For example, to refer to cells A1:A10 in Sheet2, you type Sheet2!A1:A10.
After this you will write formulas ıf you add new excel only you can add formula SheetXX!A1:A10.

Change the file name for google spreadsheet when downloaded as TSV

I have a published google spreadsheet and would like it to download as a specific file name when I download it as a TSV. The name of the file when downloaded is the name of my sheet + - Template.tsv. I need a way of changing this setting on the google end because this file will be downloaded via an HTML form, so I won't have the option to manually change the file name.

How can I automatically import & replace data in a Google Sheet from a CSV that has been uploaded to our Google Drive?

We have some marketing software that pulls reports on email marketing and uploads a CSV automatically every week or month into our Google Drive. Our reporting software can't automatically pull data from a CSV, so I have to use Google Sheets.
How can I make it so that when a new CSV is uploaded onto the Drive (replacing the old CSV in the process), my Google Sheet will pull the new data and replace it over the old data?
The question isn't clear, meaning there are many "variables" to your question, and thus a variety of solutions which you can implement to solve the specific permutation you're looking for. But I'll try to answer your question with some considerations and suggestions:
"[A] new CSV is uploaded onto the Drive (replacing the old CSV in the process)." Are you sure this is happening? Every time you upload, say a hello.csv to Drive, it adds a new hello.csv file one rather than replacing an existing one with the same name. You would have to have an application that knows or can look up the original CSV Drive file ID and explicitly replace the file contents or upload a new version of that file.
If you do replace the original file via one of those two techniques, track the changes to that file via the Drive API, meaning your app can take action as soon as that file has been updated. See this page in the docs to learn how to detect changes.
The comment in the OP makes a suggestion from another SO Q&A, however that solution does not address the OP's question. Instead, it imports a CSV file to Google Drive as a Google Sheets (file) -- the CSV file never makes it to Drive as per the OP. Also, the OP is requesting something more than a mere import.
However, with that said, the OP's final request was: "[My] Google Sheet will pull the new data and replace it over the old data." There are 2 ways to do this:
a) The simplest/easiest way is to just overwrite all existing data in the Sheet with what's in the CSV file... old data, new data, it doesn't matter. Once the new CSV file has been imported and new Sheets file created, you can delete both the old CSV and corresponding Sheet. The (new) files can have the same names as their predecessors no problem. For that, build a solution similar to the SO Q&A mentioned above -- the CSV file will already be in Drive, so just create a new Sheets file and use the content from the CSV file on Drive (rather than from the local filesystem).
b) If you only want the deltas, you need to keep a copy of the old CSV and "diff" it with the new CSV, and only overwrite the rows that have changed, a much more complex solution, and one in which you'll have to use the Google Sheets API (because it's for spreadsheet operations while the Drive API is used for file operations).

Appending a selected Range from Google Spreadsheet to a CSV file on Google Drive

I am trying to modify the following script, which saves a selected range to a new CSV file on Google drive.
https://developers.google.com/apps-script/articles/docslist_tutorial?hl=en
Please see: Section 3: Saving a selected Range to a CSV file
I would like to however append an existing CSV file with defined (named) range that I already created on Google Drive - I don't want to be prompted for its name. If and only if the CSV file not exist, then I want to create the new file.
This script should run via time-drive trigger (so that it runs automatically every minute and saves required range into csv file)
I would greatly appreciate your help how to modify this code.

Get ID folder before importing data

I have followed the code from How to automatically import data from uploaded CSV or XLS file into Google Sheets, but it does not explain how to find the folder ID that the file has been uploaded to.
I need to provide a spreadsheet template for multiple users that will facilitate the identification of the folder, since I have no way of knowing for sure where each user will save the csv file. I wish to avoid mistakes identifying the destination folder.
How can I obtain the ID of the folder where the user is importing their data?