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?
Related
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.
I have a script, which overwrites daily a Google Drive file (Google Spreadsheet) with new data. On overwriting, the file name remains the same, but the file ID changes.
I want to access the file with a Google App script scheduled daily with a time trigger to remove each daily portion of data into another file, so I'm able to make a time series report.
I know how to do this - but the method I know will work only if the file ID remains always the same - so I can't use this known method.
How can I access the file while knowing only its file name, which remains always the same, without knowing the the file ID?
I suggest you update the script that overwrites the file to just update the file. Then it's always the same file.
If that's not possible, you can search for the file using DriveApp.getFilesByName(). If you happen to know exactly which folder the file will be in, then you can narrow your query results by using Folder.getFilesByName().
Looking to automate the processing of data in a spreadsheet generated by google forms; specifically, I want to attach the files uploaded to the form to outgoing emails as attachments. The files can be synced to a local folder for the program to access, but the google form only has a url for each uploaded file.
What would be the most efficient way to determine which of the files uploaded correspond with each form submission and its corresponding link?
Edit: my research indicates that I may be able to use an identifier from the url to see which document it is through an apps api. Another thought was to scrape the html from the linked webpage and then to glean the file name from somewhere in the html here it hopefully occurs with regularity.
Then I could use the filename to construct a filepath to the synced folder on my local machine or would it be better to use the drive api to manipulate the file into an email attachment?
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).
I can upload files in root folder of Google-drive using Google-drive APIs. But I cannot upload files to non-root folders. Is it possible to upload a file in non-root folders using APIs?and DO we have any other APIs for uploading a file in non-root folders.
I am using "https://www.googleapis.com/upload/drive/v3/files" Url and I am trying to append file-Id to this Url, but I failed to upload the file to a sub-folder.
I suggest start by reading this post How do I search sub-folders and sub-sub-folders in Google Drive?. Even though the question is about searching, you will find the answer will help you to understand Drive folders. Once you realise that a Folder is really just a label, the answer will be obvious.
In simple terms, your file metadata must contain an array called "parents" (https://developers.google.com/drive/v3/reference/files#resource-representations). Simply populate that array with the file IDs of the folders you want the new file to be created in.