Created
February 6, 2025 15:28
-
-
Save DiamondStalker/8e5eb51ce32ecae532c5932eb807cffc to your computer and use it in GitHub Desktop.
Excel to json migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doGet(e){ | |
// Change Spread Sheet url | |
var ss = SpreadsheetApp.openByUrl("<spreadsheets_link>"); | |
// Sheet Name, Chnage Sheet1 to Users in Spread Sheet. Or any other name as you wish | |
var sheet = ss.getSheetByName("Usuarios"); | |
return getUsers(sheet); | |
} | |
function getUsers(sheet){ | |
var jo = {}; | |
var dataArray = []; | |
// collecting data from 2nd Row , 1st column to last row and last column | |
var rows = sheet.getRange(2,1,sheet.getLastRow()-1, sheet.getLastColumn()).getValues(); | |
for(var i = 0, l= rows.length; i<l ; i++){ | |
var dataRow = rows[i]; | |
var record = {}; | |
record['Id'] = dataRow[0]; | |
record['JobUrl'] = dataRow[1]; | |
record['HomePage'] = dataRow[2]; | |
record['Empcode'] = {"Right":dataRow[3],"Comment":dataRow[4]}; | |
record['feedcode'] = {"There_is_feedcode":dataRow[5],"Comment":dataRow[6]}; | |
dataArray.push(record); | |
} | |
jo.user = dataArray; | |
var result = JSON.stringify(jo); | |
return ContentService.createTextOutput(result).setMimeType(ContentService.MimeType.JSON); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment