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

Add examples for browsing / copying / exporting table data. #1016

Merged
merged 4 commits into from
Jul 28, 2015
Merged

Add examples for browsing / copying / exporting table data. #1016

merged 4 commits into from
Jul 28, 2015

Conversation

tseaver
Copy link
Contributor

@tseaver tseaver commented Jul 23, 2015

Uses #1014 as a base.

@tseaver tseaver added the api: bigquery Issues related to the BigQuery API. label Jul 23, 2015
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 23, 2015
@tseaver tseaver changed the title Add examples for copying / exporting table data. Add examples for browsing / copying / exporting table data. Jul 23, 2015
@dhermes
Copy link
Contributor

dhermes commented Jul 23, 2015

Will address once base is merged

@tseaver
Copy link
Contributor Author

tseaver commented Jul 24, 2015

@dhermes rebased after merge of #1014.

>>> dataset = client.dataset('dataset_name')
>>> table = dataset.table(name='person_ages')
>>> rows, next_page_token = table.data(max_results=100) # API request
>>> rows.csv.headers

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@tseaver
Copy link
Contributor Author

tseaver commented Jul 28, 2015

@dhermes PTAL.

@dhermes
Copy link
Contributor

dhermes commented Jul 28, 2015

I have a comment still un-addressed

OK. Will there be a way to access headers without the csv property?

@tseaver
Copy link
Contributor Author

tseaver commented Jul 28, 2015

The https://cloud.google.com/bigquery/docs/reference/v2/tabledata/list API doesn't show any schema in the result set, which implies that the fields must correspond to the table's schema. I had imagined that rows, when iterated, would return tuples of the values (one per row).

@dhermes
Copy link
Contributor

dhermes commented Jul 28, 2015

So how does that relate to my question. Do you plan on implementing access in another form?

@tseaver
Copy link
Contributor Author

tseaver commented Jul 28, 2015

If we can predict what people want to do, we can add helpers. Otherwise, we can document a pattern like:

for row in rows:
     for field, value in zip(table.schema, row):
          do_somthing(field, value)

@dhermes
Copy link
Contributor

dhermes commented Jul 28, 2015

Can you add that snippet to these docs? (With a spelling patch to do_somthing)

@tseaver
Copy link
Contributor Author

tseaver commented Jul 28, 2015

2624822

@dhermes
Copy link
Contributor

dhermes commented Jul 28, 2015

LGTM

tseaver added a commit that referenced this pull request Jul 28, 2015
Add examples for browsing / copying / exporting table data.
@tseaver tseaver merged commit 25545c8 into googleapis:master Jul 28, 2015
@tseaver tseaver deleted the bigquery-devx-jobs-export_copy branch July 28, 2015 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants