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

range_write: Allow modifying a single cell by providing an atomic value or a row/column with a vector instead of only accepting dataframes? #162

Open
daattali opened this issue May 25, 2020 · 2 comments
Labels
feature a feature request or enhancement

Comments

@daattali
Copy link

When I want to modify a single cell in a google sheet to the digit 5, I have to use range_write(data = data.frame(meaninglessname = 5), col_names = FALSE) and provide a data.frame with one value in it.

It would be useful if I could provide data = 5 to modify a single cell, or data = 1:5 to modify 5 cells in a row/column.

I generally understand the beauty of keeping arguments consistent in type and not trying to be clever, but since the ss and range arguments already allow variation and are trying to be as useful as possible to the user, this seems like another useful feature.

@daattali daattali changed the title Allow modifying a single cell by providing an atomic value or a row/column with a vector instead of only accepting dataframes? range_write: Allow modifying a single cell by providing an atomic value or a row/column with a vector instead of only accepting dataframes? May 25, 2020
@sanjmeh
Copy link

sanjmeh commented Jul 25, 2020

+1.
It is especially helpful when we have a large googlesheet that needs to be incrementally updated periodically and we do not want to reload the entire table while others may be updating some other parts of the sheet.

In a more general scenario we need the range also to be a vector of the same length as the data, so that we can update non continuous cells in one API call.

e.g.
range_write(data = c("OPEN", "ASSIGNED", "ROLLEDBACK" ), range = c("F7", "F13", "F32"))

This will be super efficient.
Can this be achieved through a data.frame? Am not sure.

@jennybc
Copy link
Member

jennybc commented Jul 29, 2020

Yes the general request for being able to provide data in some non-data frame format will presumably happen. I just started with data frame as the most important case.

It is especially helpful when we have a large googlesheet that needs to be incrementally updated periodically

The most common sort of incremental update can be handled with googlesheets4::sheet_append(). In general, I would always choose something where Google determines the target cell range, based on the existing shape of the data, instead of me having to determine and specify them. It's less work and less error prone. As you say, what if someone else is editing the same sheet and its dimensions change in between your calls to learn dimension (and therefore determine a target cell range) and add new data?
@sanjmeh I don't think it's likely that googlesheets4 will write to disjoint cells any time soon. You'll either need to make repeated calls to existing functions or look at the innards of our exported cell-writing functions and use the same lower-level tools (request build, make, process) to write a custom function.

@jennybc jennybc added the feature a feature request or enhancement label Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants