I am trying to upload data to firebase where the structure of my database is hierarchical. How can I manage that structure in google sheets. I have been looking for this on many websites but found nothing.
Please help. Here is the structure of my firebase
update 1
after trying the suggested model #2, i am unable to upload repeated data lines. here is my google script:
var secret = 'in2HGSgx7uMtOvqhpIzUf1tPCI97cwnzGmae5Dg1'
function getFirebaseUrl(jsonPath) {
return (
'https://sheetsdemo-8d0e9.firebaseio.com/ ' +
jsonPath +
'.json?auth=' +
secret
)
}
function syncMasterSheet(excelData)
var options = {
method: 'put',
contentType: 'application/json',
payload: JSON.stringify(excelData)
}
var fireBaseUrl = getFirebaseUrl('TimeTable')
UrlFetchApp.fetch(fireBaseUrl, options)
}
function startSync() {
var sheet = SpreadsheetApp.getActiveSheet()
//Get the number of rows and columns which contain some content
var [rows, columns] = [sheet.getLastRow(), sheet.getLastColumn()]
//Get the data contained in those rows and columns as a 2 dimensional array
var data = sheet.getRange(1, 1, rows, columns).getValues()
var dataObject = {};
for (var i = 0; i < data.length; i++) {
var dataRow = data[i];
// in cell A I have my item name and in B i have my item code
var day = dataRow[0];
var section = dataRow[1];
var course_id = dataRow[2];
var time = dataRow[3];
var course_title = dataRow[4];
var teacher = dataRow[5];
// we then create our first property on our data object dataObject.code- name : { }
dataObject[section + day] = {
day: day,
section: section,
course_id: course_id,
time: time,
course_title: course_title,
teacher: teacher
};
syncMasterSheet(dataObject)
}
}