Closed thearabbit closed 6 years ago
I can't use column to key mapping
, bc sometime use changed order column.
Now work fine
columnToKey: {
'*': '{{columnHeader}}',
},
I solved by all column, but I wold like to do any columns
Great! So, is everything ok now? Can we close this issue?
How do we cleanse header values(like replace space, dots etc in header cells with _'s ) and still do columnToKeycolumnToKey: { '*': '{{columnHeader}}', }
Did you find error while running the module because those characters were written on the header, or do you just want to "clean" the keys found on the result object?
I am looking to clean the keys present on the resultant object
something like below.
columnToKey: { "*": "{{columnHeader}}".replace(/[\W]/g, "") }
Could u tell how to do it properly? Thanks for your time :)
This module doesn't provide something on this sense. This should be a rule of your application's domain. What you can do is to clean it yourself by looping through all the keys with Object.keys().
On Wed, Aug 29, 2018, 7:24 PM Uday notifications@github.com wrote:
I am looking to clean the keys present on the resultant object
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/DiegoZoracKy/convert-excel-to-json/issues/14#issuecomment-417126747, or mute the thread https://github.com/notifications/unsubscribe-auth/AB_oP1OaYU7k7EA6E_sWvLH65t_U6RAPks5uVxSygaJpZM4WFG4M .
Thanks for your reply. How to solve?
Hi @thearabbit, how to solve what?
Now I use
columnToKey: {
A: 'id',
B: 'firstName'
}
But don't good for me, when user change order of column name
By using:
columnToKey: {
"*": "{{columnHeader}}"
}
You could get all the keys, following what is written on the header, regardless of their order.
Search for "columnHeader" on the docs to see more about it.
I would like specific like this
columnToKey: {
"ID Column": "id",
"First Name": "firstName",
"Other Column": "other"
}
Take a look at the section: "Mapping columns to keys :: Special Variables Cell Variables"
It says:
"A value from a specific cell can be defined as a key name (e.g. { A: '{{A1}}' })..."
This one and the {{columnHeader}}
are closest solutions to what you want to achieve.
Any news around here? Could you managed to handle your case with this last suggestion?
Thanks, Now I understand about this usage. 👍