Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Receiving Google sheet values
Started by sirmania May 03 2018 12:49 AM

No replies to this topic
google sheet spreadsheet values son csv table
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

sirmania

[GLOBAL: userInfoPane.html]
sirmania
  • Contributor

  • 134 posts
  • Corona SDK

I wanted to get values from Google Sheet, but that was easier said than done. I tried all tips and tricks I could find with no luck. I finally found a solution (that worked for me). I downloaded csv values and used a module to stuff them in a table.

I used this module (not created by me):

https://github.com/FourierTransformer/ftcsv

 

And got it working using this code:

-- Link to Google sheet
local URL =  "https://docs.google.com/spreadsheets/d/e/YOUR_SHEET_ID/pub?output=csv"

local ftcsv = require('ftcsv')

local function loginCallback(event)
    -- perform basic error handling
    if ( event.isError ) then
        print( "Network error!")
    else

local csvFile = event.response
local csvData, headers = ftcsv.parse(csvFile, ",", {loadFromString=true, headers=true})

				for u,k in pairs(csvData) do
					print("Number = " .. u)
						for i,l in pairs(k) do
							print( i .. " : " .. l)
				                end
				end
    end
    return true
end

network.request( URL, "GET", loginCallback )

  • Develephant and DevilDev like this


[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: google, sheet, spreadsheet, values, son, csv, table