How do you parse csv files that have different header names? I was trying to do it somewhat like this in meteor method:
parseUpload(data){
check(...)
for(let i=0;i<data.length;i++){
let item = data[i]
let thing = {
name: item.name || item.itemname || item.something,
category: item.category
}
items.insert(thing);
}
but it was always taking the first param (item.name) and as it was empty, the method couldn't be executed. How do i do OR statement to bind name to doc.namesArray so uploaded file can use aliases for column names?
also, i have noticed that when you make spreadsheet not starting from 1A, it creates empty lines/rows in csv document. papaparse still expects first column to be "name" and everything stops working again (untill i recreate csv file so it starts with actual values).