Accessing Google Sheets in Standalone – Inclusions needed?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Accessing Google Sheets in Standalone – Inclusions needed?
Hi all
I have an application that reads data from Google Sheets. See e.g. André's post here:
https://andregarzia.com/2018/11/reading ... ecode.html
When I create a standalone the data is not read in. I am wondering if I need an inclusion that I have not checked. I tried OAuth2, but that does not help.
Regards
Kaveh
I have an application that reads data from Google Sheets. See e.g. André's post here:
https://andregarzia.com/2018/11/reading ... ecode.html
When I create a standalone the data is not read in. I am wondering if I need an inclusion that I have not checked. I tried OAuth2, but that does not help.
Regards
Kaveh
Kaveh
Re: Accessing Google Sheets in Standalone – Inclusions needed?
Hi Kaveh,
I compiled André's example and chose "search for required inclusions..." in the standalone settings. It included the tsNet external. The standalone worked just as well as in the IDE.
May be either try to include tsNet external or choose "search for required inclusions..."
But then I am not an expert on network questions, let alone Google Sheets.
Kind regards
Bernd
I compiled André's example and chose "search for required inclusions..." in the standalone settings. It included the tsNet external. The standalone worked just as well as in the IDE.
May be either try to include tsNet external or choose "search for required inclusions..."
But then I am not an expert on network questions, let alone Google Sheets.
Kind regards
Bernd
Re: Accessing Google Sheets in Standalone – Inclusions needed?
Got it. I am importing JSON so needed to add JSON library.
Kaveh
Re: Accessing Google Sheets in Standalone – Inclusions needed?
Thanks bn. I should have said I am doing Json import. For some reason I switched to manually adding inclusions a while ago...
Kaveh
Re: Accessing Google Sheets in Standalone – Inclusions needed?
I suspect that reason might have been the automatic search had a failure at some point. Lots of others *only* use the manual inclusions methods.
Not me of course, but I only do such simple things
Not me of course, but I only do such simple things


-
- Livecode Opensource Backer
- Posts: 10121
- Joined: Fri Feb 19, 2010 10:17 am
Re: Accessing Google Sheets in Standalone – Inclusions needed?
Are you trying to read the information from Google Sheets from a web address?
or from a downloaded file?
Personally, I'm a lazy slob and download the Google Sheets as CSV documents
and just go for importing comma-delimited text files into
a Table Field: no special inclusions or additional twiddly bits at all.
As far as I can tell from Andre's 'thing' what it does is extract a CSV document from the online Google Sheet thereby obviating the need for the
end-user to just do this:
-
or from a downloaded file?
Personally, I'm a lazy slob and download the Google Sheets as CSV documents
and just go for importing comma-delimited text files into
a Table Field: no special inclusions or additional twiddly bits at all.

As far as I can tell from Andre's 'thing' what it does is extract a CSV document from the online Google Sheet thereby obviating the need for the
end-user to just do this:
-
Last edited by richmond62 on Wed Sep 25, 2019 6:11 pm, edited 1 time in total.
Re: Accessing Google Sheets in Standalone – Inclusions needed?
Hi richmond. I need to import the data automatically and on the fly, not manual download. A problem with csv was that it did not respect returns *within* cells. Somehow this was fixed by getting json. Needed some expert outside help with that...
The only problem I have now is that Unicode chars are corrupted on import into LiveCode. See this lonely post:
https://forums.livecode.com/viewtopic.p ... on#p182782
The only problem I have now is that Unicode chars are corrupted on import into LiveCode. See this lonely post:
https://forums.livecode.com/viewtopic.p ... on#p182782
Kaveh
-
- Livecode Opensource Backer
- Posts: 10121
- Joined: Fri Feb 19, 2010 10:17 am
Re: Accessing Google Sheets in Standalone – Inclusions needed?
Aha; now I see where the difficulty lies.on the fly, not manual download.
The problem with Unicode characters: is that via CSV or via JSON, or both?
Be aware that, inspite of the "ballyhoo" LiveCode is not completely 'there' when it comes to Unicode.
I, personally, know that LiveCode can import .txt and .html files containing Unicode text without
everything ending up like a jam sandwich.
-
- Livecode Opensource Backer
- Posts: 10121
- Joined: Fri Feb 19, 2010 10:17 am
Re: Accessing Google Sheets in Standalone – Inclusions needed?
I exported a sheet from Google Sheets with some Unicode Text in it to a .csv file on my Macintosh and
attempted to bring it into a Table field:
and it DID muck up the Unicode.
"Just for fun" I opened the .csv file in LibreOffice where it, usefully, told me that it was in UTF-8 encoding.
So I popped over here: https://forums.livecode.com/viewtopic.php?t=31205
And modified my code accordingly:
and the thing worked.
-
attempted to bring it into a Table field:
Code: Select all
on mouseUp
answer file "Choose a text file to import"
if the result = "cancel"
then exit mouseUp
else
put URL ("file:" & it) into SeeEssVee
--replace commas with tabs
replace "," with numToChar(9) in SeeEssVee
set the text of fld "champs" to SeeEssVee
end if
end mouseUp
"Just for fun" I opened the .csv file in LibreOffice where it, usefully, told me that it was in UTF-8 encoding.
So I popped over here: https://forums.livecode.com/viewtopic.php?t=31205
And modified my code accordingly:
Code: Select all
on mouseUp
answer file "Choose a text file to import"
if the result = "cancel"
then exit mouseUp
else
put URL ("file:" & it) into SeeEssVee
put textdecode(SeeEssVee,"UTF-8") into Jumping
--replace commas with tabs
replace "," with numToChar(9) in Jumping
set the text of fld "champs" to Jumping
end if
end mouseUp

-
- Attachments
-
- HereItIs.zip
- Folder containing the stack and the CSV file exported from Google sheets I used to test the thing.
- (2.21 KiB) Downloaded 293 times
-
- Livecode Opensource Backer
- Posts: 10121
- Joined: Fri Feb 19, 2010 10:17 am
Re: Accessing Google Sheets in Standalone – Inclusions needed?
DO you mean that when you exported a sheet to a CSV document the returns were not respectedA problem with csv was that it did not respect returns *within* cells.
(i.e. ignored or replaced with something else)?
Because to me this makes little or no sense as when I attempted a return in Google Sheets it
changed focus from a cell to the next one vertically below it.
So my first question has to be:
#1 How did you manage to prepare a Google Sheets document that included returns in cells?
(The only way that seems possible to me is that you imported data that contained returns into cells from
somewhere else.)
If your CSV document replaced any returns consistently
with another character it should be easy enough to replace that character once again
with returns once it has been imported into LiveCode
in exactly the same way as I replaced commas with tabs.

-
- Livecode Opensource Backer
- Posts: 10121
- Joined: Fri Feb 19, 2010 10:17 am
Re: Accessing Google Sheets in Standalone – Inclusions needed?
Thanks for all that: because of your provocation I learnt how to use
replace; a term I didn't even know about until about 30 minutes ago.
The whole replace thing makes me feel rather stupid,
having used repeat loops chewing through texts char by char for years.
replace; a term I didn't even know about until about 30 minutes ago.

The whole replace thing makes me feel rather stupid,
having used repeat loops chewing through texts char by char for years.

Re: Accessing Google Sheets in Standalone – Inclusions needed?
Hi Richmond. Thank you for the multiple contributions. While I am going through them, putting a return into a cell in Google Sheets is achieved by Option-return (or Command-return). I know you are a mac user. I am guessing control for other operating systems.
Kaveh
-
- Livecode Opensource Backer
- Posts: 10121
- Joined: Fri Feb 19, 2010 10:17 am
Re: Accessing Google Sheets in Standalone – Inclusions needed?
Well; sometimes, but my "other car is a Lamborghini," . . . I use Linux at least as much as I use Macintosh.I know you are a mac user.
Not that that, frankly, is terribly relevant here.
So, I added 2 cells to my Google sheet with returns: here's what the exported .csv file looks like
in LibreOffice:
- -
So, lets' see what happens if I import it into my stack:
- -
Well, that's a load of old toadstools for 2 reasons:
#1 views return in the same way as it view tab.
#2 bungs quotes round English words.
So: it is probably time to be clever by replacing the standard linefeed char in a .csv file: numToChar(10)
with another of the Unicode linefeed possibilities and see if that works:
- -
HOWEVER, in my timezone it is well past my bedtime, so,
either you'll have to have a bash at that, or wait until about 20 hours from now
when I am home from tomorrow's teaching.

Re: Accessing Google Sheets in Standalone – Inclusions needed?
Your replies will be worth waiting for!! By the way did you see this thread:
https://forums.livecode.com/viewtopic.p ... eh#p182337
regarding the returns
https://forums.livecode.com/viewtopic.p ... eh#p182337
regarding the returns
Kaveh
-
- Livecode Opensource Backer
- Posts: 10121
- Joined: Fri Feb 19, 2010 10:17 am
Re: Accessing Google Sheets in Standalone – Inclusions needed?
The situation where importing data from a .csv document bungs quotes round text is inconsistent
as it does NOT do that for "Джон", so is presumably (?) confined only to the old, old ASCII range
of characters. It is also unasked for and not required.
HOWEVER, doing this:
replace numToChar(34) with numToChar(0) in Jumping
does something that is also problematic:
- - -
It seems that every word that has a double quote preceding it gets deleted!
as it does NOT do that for "Джон", so is presumably (?) confined only to the old, old ASCII range
of characters. It is also unasked for and not required.
HOWEVER, doing this:
Code: Select all
on mouseUp
answer file "Choose a text file to import"
if the result = "cancel"
then exit mouseUp
else
put URL ("file:" & it) into SeeEssVee
put textdecode(SeeEssVee,"UTF-8") into Jumping
--replace commas with tabs
replace "," with numToChar(9) in Jumping
--remove quotes
replace numToChar(34) with numToChar(0)
set the text of fld "champs" to Jumping
end if
end mouseUp
does something that is also problematic:
- - -
It seems that every word that has a double quote preceding it gets deleted!