Google-sheets – IMPORTDATA Google Sheet CSV on Google Drive

csvgoogle sheetsgoogle-driveimportdata

So I'm starting to really get into utilizing Google Drive to streamline my many personal projects. One of the things I'd love to do is figure out how to download CSV files onto my Google Drive, and have Google Sheets automatically do an =IMPORTDATA on any new .csv files in a specific directory.

I've come across a number of problems trying to figure this out, but the biggest issue is that putting any kind of file on the Google Drive doesn't give you a link to the file itself, but rather something like such:

https://drive.google.com/a/xxxx/file/x/xxxxxxxxxxxxxxxx/view?usp=sharing

=IMPORTDATA doesn't recognize this as a .csv file.

How can I go about doing this?

Best Answer

Generating a direct download link, as described in this article seems to work fine with the =IMPORTDATA function.

To summarize, you take the SITE_ID string from the sharing link you have:

https://drive.google.com/file/d/FILE_ID/edit?usp=sharing

Using this, you can generate the direct download link for use with the =IMPORTDATA function:

https://drive.google.com/uc?export=download&id=FILE_ID