ata = {}
HttpService = game:GetService("HttpService")
function Data:GetSpreadsheet(Key)
if not Key or Key == "" then return "" end
local success, result = pcall(function()
local GetData = HttpService:GetAsync("https://docs.google.com/spreadsheet/tq?key="..Key, false)
local StartLocation = string.find(GetData,"setResponse")+12
local EndLocation = string.len(GetData)-2
local JsonData = string.sub(GetData, StartLocation, EndLocation)
return HttpService:JSONDecode(JsonData)
end)
if not success then
warn(result)
return ""
else
return result
end
end
function Data:ToArray(spreadsheet, columnScheme)
local tab = {}
pcall(function()
for i = 1, #spreadsheet.table.rows do
local rowTab = {}
local columns = spreadsheet.table.rows[i].c
for j = 1, #columns do
local index = j
if columnScheme == "Alphabetical" then
index = spreadsheet.table.cols[j].id
elseif columnScheme == "Labels" then
index = spreadsheet.table.cols[j].label
end
if columns[j] then
rowTab[index] = columns[j].v
end
end
tab[i] = rowTab
end
end)
return tab
end
function Data:SearchData(Array, columnOneName, columnOneValue, columnTwoName)
local columnTwoValue = nil
for i = 1, #Array do
for j, v in pairs(Array[i]) do
if j == columnOneName and v == columnOneValue then
for j, v in pairs(Array[i]) do
if j == columnTwoName then
columnTwoValue = v
end
end
end
end
end
return columnTwoValue
end
return Data
