Problem:
In Google Sheets, I use the IMPORTDATA function with an API call to a 3rd party data provider that frequently produces a text string that is longer than the cell limit of 50,000 characters. I have no control over the length of the text string that is provided to me, and when the 50,000 character limit is exceeded, I end up with no data at all.
Question:
Is there any way to use scripting for the API call (to avoid the 50,000 character limit) - and then parse that data to two or more cells so that the cell limit is not exceeded?
My suggestion would be to use Google Apps Scripts to make the API call. That will return your data as JSON, a string, or some other data type depending on how the API returns data.
Once you have the data in your Google Apps Script you could split the data out into smaller chunks. There are lots of JavaScript string methods for that. You can convert JSON to a compact string using JSON.stringify(yourJSONObject). Once you have your data split out how you want, you can use the Google Sheets API (https://developers.google.com/sheets/api/quickstart/apps-script) to insert the cells you need.
On a side note, I know it says the character limit is 50K everywhere you look, but I have been adding cells that have close to 500K characters in them. Perhaps that is because it is my work account which has G Suite. I would like to read some documentation somewhere on why I can enter way more than 50K characters in a cell.
Documentation on API Calls in Google Apps Scripts:
https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app
https://developers.google.com/apps-script/guides/services/external
Related
As GOOGLEFINANCE() seems very limited in the cryptocurrencies it supports, are there any (free?) APIs that I can use to get data from?
Although I use GF() for ETH and BTC, I'm specifically looking for Price and Historical Closing Prices on ADA (Cardano).
I've searched the forum for suggestions, there aren't many and most are old. Binance's API seemed OK, but it gives prices in USDT instead of USD.
If anyone is interested, I found an API that offers a free key, although limited in the number of daily calls you can make: CoinAPI.
It seems very powerful, with quotes available in most currencies. So far, I've managed to get a current price:
Formulas shown in brown.
(1) shows the raw data returned, a two rows delimited by semi-colons.
(2) wraps a QUERY() around IMPORTDATA(), using offset 1 plus param 0, to not return the header row, then wraps all that in SPLIT() to separate the delimited text into columns.
(3) wraps (2) with INDEX() so I can get just the Price in the 4th col.
As this value will not automatically update like GOOGLEFINANCE(), I think I'll need to set a Trigger to do that.
I've also retrieved historical data, but I've yet to figure out how to split multiple rows of delimited text from the IMPORTDATA() function.
[Edit] See the solution to splitting multiple rows by #player0 at https://stackoverflow.com/a/69055990/190925.
I want to append a row of cells to a google sheet and also attach some developer metadata to that row.
In the Google Sheets v4 API, I know you can use batchUpdate to append a row with the appendCells request, and you can add developer metadata using the createDeveloperMetadata request.
My issue is that I wanna set some developer metadata to specifically the newly appended cells atomically. There's not really a way to specifically ensure the range of the newly added row in createDeveloperMetadata, and if I use two different requests, someone else may insert a row between those requests which could shift all the rows, causing the appended cell's range to be pointing to an incorrect row.
Is there a way to attach developer metadata to a newly added cell atomically?
Answer:
There is not currently way of ensuring that the sheet structure hasn't changed between requests.
More Information:
Your The best option, I think, is to make two sequential requests in the same batch. Though this isn't foolproof, in very unlucky circumstances. Even inserting the row directly using an UpdateCellsRequest isn't foolproof either, as simply knowing which row you inserted the data doesn't exclude the possibility that someone else may insert/delete a row before it between the two requests.
Feature Request:
You can however let Google know that this is a feature that is important for the Sheets API and that you would like to request they implement it. Google's Issue Tracker is a place for developers to report issues and make feature requests for their development services.
The page to file a Feature Request for the Google Sheets API is here.
References:
Requests - UpdateCellsRequest | Sheets API | Google Developers
Requests - AppendCellsRequest | Sheets API | Google Developers
The solution I figured out was essentially:
Fetch the dimensions of the sheet
Perform a batch update with insertDimension, updateCells, and createDeveloperMetadata all performed for the same sheet dimension index at the end of the sheet
This basically ensures that the dimension index will point to the same row for all 3 operations in the batch update, and if the index points out of bounds, all 3 operations will fail
We have a BigQuery table whose data is coming from a Google Sheet. Occasionally, querying from that sheet breaks because there are cells that start with + character.
Example:
+search +terms
The query result responds with:
Which is not really a formula or something; I just want that text to appear in BigQuery as is.
Manually placing a prefix apostrophe ' on that cell (or the column where those cells belong) will work for that query instance. But because new data comes automatically at no set schedule, makes that procedure out of question.
Is there some option in BigQuery that we can set so it interpret such texts literally?
You might be aware of the fact that + and # are actually reserved characters in Google sheets, entering the desired function you want to use in the particular cell.
Mentioned above, If you don't want to supply a predefined formula function after typing one of these special signs, consider adjusting quotation marks (" ",' ') to detach the user data.
As long as Bigquery leverages Sheets data connector to deal with Google spreadsheets it is not equipped with any of instruments to intercept the broken cells #NAME?, thus the hand on intervention should be performed in the relevant sheet file in order to align the columns with an actual context.
As a quick solution looking for some concerns, you might be able to fetch the context from #NAME? cell adopting FORMULATEXT() function in neighboring rows as well:
FORMULATEXT(cell)
or replace some symbols:
SUBSTITUTE(FORMULATEXT(cell),"=","+")
I am trying to build a daily tracker for my work group and have been pulling the data from a weburl using IMPORTHTML function. But often the function fails saying Resource at url contents exceeded maximum size. What is the limit on the rows that can be imported using IMPORTHTML? It seems to be breaking somewhere around 10k rows.
If I have to import more rows than that, say 100k, what is the best way to do that?
You can use apps script to accomplish it.
With UrlFetchApp you can get all the data from your url.
Once you have the data you can use SpreadsheetApp to insert these data in the sheet.
I have been looking for a solution to convert a database I have with HTML formatting in one of the columns to its "normal" text equivalency in google sheets. A lot of the solutions I've found dealt with writing programs to do this or using Excel, so they unfortunately didn't pertain well enough.
For example in one of my columns I have;
Fast (<i> This character deals damage before non-<b>Fast</b> characters in combat.</i>)
But I would like to be able to have a somewhat streamlined solution to convert the above to:
Fast (This character deals damage before non-Fast characters in combat.)
AFAIK, with Google Sheet API, you can only format text within a cell. As mentioned in documentation, conditional formatting lets you format cells so that their appearance changes dynamically according to the value they contain, or to values in other cells.
You may want to request new feature here.