Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: How to get specific fields when listing files. #42

Open
Cing2 opened this issue Jun 2, 2020 · 10 comments
Open

docs: How to get specific fields when listing files. #42

Cing2 opened this issue Jun 2, 2020 · 10 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Cing2
Copy link

Cing2 commented Jun 2, 2020

Hey,

How is it going with this project? I am planning to use this for my own project and was trying some things. However I could not find how to get certain fields of a file, like id, name, parents. etc..
The documentation also isn't clear this one.
I am willing to help with the project, to get it more usable. Love to hear from you.

Regards,

@Cing2 Cing2 changed the title How to get specific fields when retrieving data. How to get specific fields when listing files. Jun 2, 2020
@shcheklein
Copy link
Member

@Cing2

How is it going with this project?

it is actively maintained, at least as long as `iterative/dvc is alive and maintained.

However I could not find how to get certain fields of a file, like id, name, parents. etc

I assume you already found the file listing API - https://pythonhosted.org/PyDrive/filelist.html#file-listing-made-easy right? Then it already has a small example how to get title and id (and the same way you can access other file attributes). Am I missing something in your question?

@shcheklein shcheklein added question Further information is requested triage documentation Improvements or additions to documentation labels Jun 2, 2020
@Cing2
Copy link
Author

Cing2 commented Jun 2, 2020

Yes, I can see how get the attributes after the download. But how do you select to only download the attributes you need. Which will reduce data and time needed.
https://developers.google.com/drive/api/v3/reference/files/list
in the docs you can have an parameter 'fields', to select the attributes you need.

@shcheklein
Copy link
Member

shcheklein commented Jun 2, 2020

Have you tried to pass param={"fields": ...} to the list call? .. I think it should support it as well.

@Cing2
Copy link
Author

Cing2 commented Jun 3, 2020

Yes I did but got an ApiRequestError.
This is what I tried:

file_list = drive.ListFile({'fields': 'id, name',
                            'q': "'root' in parents and trashed=false"}).GetList()

@shcheklein
Copy link
Member

Try this: 'fields': 'items(id,title)' - check the API docs for the exact syntax on how to specify the list of fields you'd like to get.

@Cing2
Copy link
Author

Cing2 commented Jun 3, 2020

Thank you, I see now that you are still using the v2 version. Although this is not clear on the home page.

@shcheklein
Copy link
Member

Yes, but I think the syntax for fields is the same across v2 and v3 - check these examples https://developers.google.com/drive/api/v3/fields-parameter

@Cing2
Copy link
Author

Cing2 commented Jun 3, 2020

Ah oke, I was looking at this one: https://developers.google.com/drive/api/v3/search-files

@shcheklein
Copy link
Member

@Cing2 sure. I keep it open with the documentation label. Hopefully we'll get a contribution to improve it and put some examples.

@shcheklein shcheklein changed the title How to get specific fields when listing files. docs: How to get specific fields when listing files. Jun 3, 2020
@shcheklein shcheklein added good first issue Good for newcomers help wanted Extra attention is needed and removed triage labels Jun 3, 2020
@shcheklein shcheklein removed the question Further information is requested label Feb 2, 2021
@tisalvadores
Copy link

Hi,
I think this issue shouldn't be handled just by changing the documentation.
v3 has some field differencies with v2. At least: 'fields': 'items(title)' vs 'fields': 'files(name)'

As v3 has been out for many years, it is natural for people to develop using the v3 documentation as reference (my case). I couldn't figure out why I could download specific fields only with the API and not with PyDrive2, and the only explanation I could find is this issue.

Can PyDrive2 be updated to use the v3 fields?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants