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 rake task for importing annotations #233

Merged
merged 2 commits into from
Feb 28, 2018
Merged

Conversation

Mr0grog
Copy link
Member

@Mr0grog Mr0grog commented Feb 23, 2018

I was working on some other Ruby + Google Sheets code today, so I took a little extra time for this. We can use it to solve #61 (but that issue is about the work of running this script, not about the script itself).

Use the import_annotations_from_sheet rake task to import all the annotations an analyst has created in a given Google Sheet. This can be used to solve #61.

Arguments are:

  1. Google sheet ID, e.g. 1-Rq-AclS2GI_yxLmkYVY7FvTfN21KoJtxXtOXXXXXX
  2. E-mail of user to attribute the annotation to
  3. (optional) Name of spreadsheet tabs to import (comma-separated). If unset, all tabs will be imported.
  4. (optional) Row to start at (defaults to 7)
  5. (optional) Row to end at. If unset, reads all rows.

When done, it'll output summary information of how many rows were added, skipped, or errored across how many tabs.

Example:

$ rake import_annotations_from_sheet['1-Rq-AclS2GI_yxLmkYVY7FvTfN21KoJtxXtOXXXXXX','[email protected]']
> Importing spreadsheet tab '1 EPA About OECA'
> Importing spreadsheet tab '1 HHS Climate & Env'
> 
> RESULTS:
> --------
> Created 253 annotations
> Skipped 0 rows
> Errored 0 rows
> In      2 spreadsheet tabs

If you set the VERBOSE environment variable (to any value) it'll print information about every row that produced an annotation.

Use the import_annotations_from_sheet to import all the annotations an analyst has created in a given Google Sheet. This can be used to solve #61.

Arguments are:
1. Google sheet ID, e.g. 1-Rq-AclS2GI_yxLmkYVY7FvTfN21KoJtxXtOXXXXXX
2. E-mail of user to attribute the annotation to
3. (optional) Name of spreadsheet tabs to import (comma-separated). If unset, all tabs will be imported.
4. (optional) Row to start at (defaults to 7)
5. (optional) Row to end at. If unset, reads all rows.

When done, it'll output summary information of how many rows were added, skipped, or errored across how many tabs.
Copy link
Contributor

@danielballan danielballan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name of spreadsheet tabs to import (comma-separated).

It looks like spreadsheet names can have commas, but they can't have colons. A comma is a more obvious choice for a separator. A colon is a technically safe one. Given that this is a tool to solve a temporary problem and that we don't have commas in our spreadsheet names, it seems reasonable to stick with a comma separately -- I was just curious so I thought I'd mention it.

@Mr0grog
Copy link
Member Author

Mr0grog commented Feb 27, 2018

I think you’ve already thought about this more than I did! I’m not sure about the colons, though—I just tried using one as a tab title and it seemed to work. Maybe we’re talking about different things?

screen shot 2018-02-26 at 9 29 57 pm

@danielballan
Copy link
Contributor

I found that claim on this Microsoft support page:

Worksheet names cannot: [...] Contain any of the following characters: / \ ? * : [ ]

I guess Google Sheets went their own way on this one. Let's go with commas and assume we won't hit this bug during the finite period we will be using this feature.

@Mr0grog
Copy link
Member Author

Mr0grog commented Feb 28, 2018

Oh, that is an interesting difference. I’ll go ahead and merge this, then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants