I am iterating through .csv file to do some element level validation in angular js app. I couldn't find better library in angular so i started writing custom javascript to handle this scenario. Below is the attached data sample ( interested in first column CN and 5th column NAME data ). All i could think of is few if conditions to check the index of i, j and store the values. Any suggestions would be appreciated.
CN N ACTIVE TYPE NAME NO COM
USA 45 Engin Fed Anderson #10 NA
USA 46 Sports BB Kobe #1 NA
USA 32 Sports Soccer Kobe #17 NA
GER 30 Sports Soccer Gotze #12 NA
GER 27 Sports Soccer Ozil #18 NA
ITA 38 Sports Soccer Buffon #2 NA
code snippet
for ( var i=0; i< file.length; i++ ){
var singleRowData = file[i].split(',');
singleRowData = singleRowData.filter(function(n){ return n != "" });
for ( var j=0; j< singleRowData.length; j++){
duplicateFunction(singleRowData, singleRowData[j], j, i);
}
}
function duplicateFunction ( singleRowData, singleRowDataElement, singleRowDataElementIndex, singleRowDataIndex){
/*
handle the duplicates
*/
}
- If I find same values in CN column for consecutive rows then i would like to check if i have duplicate values in NAME column for those rows.
- If i don't have duplicate NAME for different rows of same CN values ( different rows ) then i shouldn't throw error.
In this data example, I should catch exception on 3rd row for CN = USA, NAME=Kobe and rest of the data should work fine