CSV Import with column name as a number gives error
#6 503 ouverte le 14 déc. 2017
Métriques du dépôt
- Stars
- (5 395 stars)
- Métriques de merge PR
- (Aucune PR mergée en 30 j)
Description
Hello There,
I am trying to import a csv with numbers and strings in first row. This numbers & strings needs to be column headers which are actually product ids in my application.
Eg: customer_id, customer_name,8,7,3
This produces error: Uncaught TypeError: value.replace is not a function
I fixed this issue with below
processHeaders: function( grid, headerRow ) { var headers = []; if ( !grid.options.columnDefs || grid.options.columnDefs.length === 0 ){ // we are going to create new columnDefs for all these columns, so just remove // spaces from the names to create fields headerRow.forEach( function( value, index ) { if(typeof value !== 'number'){ headers.push( value.replace( /[^0-9a-zA-Z-]/g, '' ) ); } else { headers.push( value); } }); return headers; } else { var lookupHash = service.flattenColumnDefs( grid, grid.options.columnDefs ); headerRow.forEach( function( value, index ) { if ( lookupHash[value] ) { headers.push( lookupHash[value] ); } else if ( lookupHash[ value.toLowerCase() ] ) { headers.push( lookupHash[ value.toLowerCase() ] ); } else { headers.push( null ); } }); return headers; } },
Now the issue is that the position of the column changes. Its no more the same as in the csv. The column names which are a string are pushed to the end and the numbers are listed first.
Attaching the csv file upload.txt Please change the extenstion to .csv i have changed it to .txt as .csv is not supported here.