Trying to remove whitespace from a column header
See original GitHub issueThis is really two questions in one. Hopefully someone can help me…
I have a lambda function written in node.js which uses the library to convert an excel spreadsheet into JSON. This was working fine except for that some of the column headers had whitespace at the end. I was trying to remove it by adding the code below (in visual studio code), which I found in another issue.
https://github.com/SheetJS/js-xlsx/issues/443#event-1012916154
var range = XLSX.utils.decode_range(ws['!ref']);
for(var R = range.s.r; R <= range.e.r; ++R){
for(var C = range.s.c; C <= range.e.c; ++C) {
var coord = XLSX.utils.encode_cell({r:R, c:C}), cell = ws[coord];
if(!cell || !cell.v) continue;
// clean up raw value of string cells
if(cell.t == 's') cell.v = cell.v.trim();
// clean up formatted text
if(cell.w) cell.w = cell.w.trim();
}
}
Instead of removing white space it removed the entire column. When I reverse these changes the column was still missing when I ran the previously working code.
- Does anyone know why column is still missing when I have reverted to the original code?
- How can I trim just the white space from a column header with this library?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How can I strip the whitespace from Pandas DataFrame ...
I am parsing data from an Excel file that has extra white space in some of the column headings. When ...
Read more >How to remove trailing whitespaces from column headers in ...
In this blog post we'll do a small thing to remove trailing or leading whitespaces from a DataFrame's column names.
Read more >Remove spaces from column names in Pandas - GeeksforGeeks
Removing spaces from column names in pandas is not very hard we easily remove spaces from column names in pandas using replace() function....
Read more >Need to remove whitespace from datatable specific column
Above query helps you remove all extra white spaces and write data back to the DataTable. Replace ColumnName with actual column the one...
Read more >Pyspark – Remove Spaces From DataFrame Column Header
In modern era of data world, when we load data into our data lake we try to implement some standardization's example: Naming Standards, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If a column is missing, likely the header label is missing or the range is incorrect.
To trim column headers:
We also wanted to trim headers, this is what we used. Lodash - mapKeys (docs) Hope this helps.