Pass list of google drive file URLs to dataframe - python

I have a google sheet with a column of URLs to other google sheets, each of which could either be a native google sheet or an excel file uploaded to the Drive. All the files are stored in my work Google Drive, so the share link provides access for anyone within the company.
My research revealed several ways to access individual Google Drive files or all files in a particular directory, but I'm hoping to find a way to access hundreds of other file URLs and read each of them (and their tabs) to a separate pandas dataframe.
I could go through the process of creating shortcuts for each of the files to a folder on my drive and go the "pull in everything from this directory" route, but before I subject myself to the tedium I thought I'd put myself out there and ask.

Related

Retrieve File ID's from mounted Google drive via Google Colab

I have generated multiple files and stored them in a directory on Google Drive.
I want to retrieve the File IDs of those files such that I can use them in my python script further down-stream in the following way:
col='image'
df[col] = f'https://drive.google.com/file/d/'+df['ID']+'
Where df['ID'] contains the required File IDs in my pd.DataFrame.
As I am very inexperienced in this regard I would like to ask whether it is possible to:
retrieve these File IDs in an easy way e.g. via a bash command (similar to ls) or directly via python without using the Drive API.
alternatively, store the File IDs while generating the files in my Colab notebook.
Thanks in advance for the help! :-)

Sending Python File Storage Type to Google Drive

i am new in the world of programming and python. I have a small flask app that consists of a form that ask users to upload a certain document. That document i then store into a variable in my python script called
file_upload = request.files['filename']
I want to send this same file storage into a folder i have in google drive.
The problem i am having is that every tutorial that i see is uploading files from a path in their computers, but i havent seen one that doesnt use a folder path.
(btw i am using GOOGLE APP ENGINE which doesnt allow me to store the file first to a directory and then to google drive)

Python reading a public google spreadsheet with no share option

Can I read a google spreadsheet which is open to people, but doesn't have a share option? There's a discussion here, but it's I need to have an authorization to click the share option.
Even copying by URL to my own Google spreadsheet may serve the purpose.
Update:
The idea was once I create a Google API, I should be able to create a .json file with a client email. In the share option, I'm supposed to provide the client email of .json file. You may see: Accessing Google Spreadsheet Data using Python.
This is the spreadsheet page where I'm not finding any Share option: https://docs.google.com/spreadsheets/d/e/2PACX-1vSc_2y5N0I67wDU38DjDh35IZSIS30rQf7_NYZhtYYGU1jJYT6_kDx4YpF-qw0LSlGsBYP8pqM_a1Pd/pubhtml#
Issue:
Publishing the contents of a spreadsheet to the web is not the same as making a spreadsheet public.
The URL you shared refers to spreadsheet contents that were published to the web following these steps. This published website is not the same as the original file where the data comes from, and so it doesn't have most of its functionalities, like a Share button (it doesn't make sense to have a Share button anyway, since this URL is already public).
Solution:
If you want to access the spreadsheet data using a Service Account, you would have to do one of the following (better to use method 1 if you have access to the spreadsheet):
Share the spreadsheet itself (not the published contents) with the Service Account, as explained in the link you referenced.
Use your application to fetch the website contents from the provided URL.
Reference:
Make Google Docs, Sheets, Slides & Forms public

Saving Spreadsheet to Folder in Google Sheets API (Python)

I am working with the Google Sheets API in Python but am having trouble finding out how to save a newly created Spreadsheet to a specific folder. As of now all it does is populate my drive without the ability to indicate an end location. Any idea how to do this in Python?
I have found help with other languages but the python documentation is much different. Any insight would be great...

BigQuery: loading excel file

Is there any way we can load direct excel file into BigQuery, instead of converting to CSV.
I get the files every days in excel format and need to load into BigQuery. Right now converting into CSV manually and loading into BigQuery.
Planning to schedule the job.
If not possible to load the excel files directly into BigQuery then I need to write a process(Python) to convert into CSV before loading into BigQuery.
Please let me know if any better options are there.
Thanks,
I think you could achieve above in a few clicks, without any code.
You need to use Google Drive and external (federated) tables.
1) You could upload manually you excel files to Google Drive or synchronise them
2) In Google Drive Settings find:
"**Convert uploads** [x] Convert uploaded files to Google Docs editor format"
and check it.
To access above option go to https://drive.google.com/drive/my-drive, click on the Gear settings icon and then choose Settings.
Now you excel files will be accessible by Big Query
3) Last part: https://cloud.google.com/bigquery/external-data-drive
You could access you excel file by URI: https://cloud.google.com/bigquery/external-data-drive#drive-uri and then create table manually using above uri.
You could do last step also by API.

Categories