4

I'm trying to write a Google Sheet App script that bulk import CSV files into a single sheet in a google sheet.

Every week my server is sending me a CSV file reporting with some updated data from my database. Each CSV file has exactly the same structure, since it's the same report and only date is changing.

I automatically download all the csv in a single Folder on Google Drive Is there a way to build a script that scans the folder, open the first CSV file fills a Google sheet with the data (and the date of the CSV report) deletes the current CSV from the folder then moves to the next CSV files.

kgf3JfUtW
  • 13,702
  • 10
  • 57
  • 80
  • Yes, there is a way. I'd say this is a duplicate question. There is an answer to this posted here: https://stackoverflow.com/questions/26854563/how-to-automatically-import-data-from-uploaded-csv-or-xls-file-into-google-sheet – Randy D Dec 04 '17 at 16:26
  • Thank you @RandyD It seems like the question was not similar but the answer given is definitely helping me ! thanks again – Jonathan Sportiche Dec 05 '17 at 14:51

2 Answers2

2

if you dont want to mess around with code, you might as well us this add-on: https://www.sheetgo.com/

Worked well for us. :)

0

To scan/search for files in the drive, here is what you need.

You can search for files with the files.list method of the Drive API. Domain administrators may also search for Team Drives in the organization with the teamdrives.admin.list method.

Open and convert Google Docs in your app.

An app registered with the Import option enabled in the Drive UI Integration tab within the Drive API in the API Console can import supported Google Doc formats. This means that if a user selects Open with for a Google doc, the app can convert it to a format that the app can handle. When Open with triggers a conversion this way, Drive evaluates the MIME types an app can open (set during registration) and extrapolates the list of formats that the app can import.

Google doc formats are listed in the documentation.

And to manipulate the sheets you will open, you can refer here.

The Sheets API allows you to create sheets, delete sheets, and control their properties. The examples on this page illustrate how some common sheet operations can be achieved with the API.

For further info, you can refer from here and here.

MαπμQμαπkγVπ.0
  • 5,887
  • 1
  • 27
  • 65