-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSV.gs
More file actions
27 lines (24 loc) · 752 Bytes
/
CSV.gs
File metadata and controls
27 lines (24 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function getLogsfromCsvs(csvFiles){
var csvs = getClockSharkCsvs(csvFiles);
return csvs.reduce(function(acc,csv,index){
return acc.concat(getObjectListfromCsv(csv, csvFiles[index].getId(), csvFiles[index].getName()));
},[]);
}
function getClockSharkCsvs(files) {
return files.map(function(file){
return Utilities.parseCsv(file.getBlob().getDataAsString())
});
}
function getObjectListfromCsv(csv,fileId, fileName){
var keys = csv.shift().map(_.firstLetterLowerCase);
return csv.map(function(row, rowIndex){
var item = row.reduce(function(acc,cell,index){
acc[keys[index]] = cell;
return acc;
},{});
item.fileId = fileId;
item.fileName = fileName;
item.rowIndex = rowIndex+2;
return item;
});
}