cancel
Showing results for 
Search instead for 
Did you mean: 

Adding column at the beginnging of mapped array

SL12345
New Contributor III

Hi snaplogic experts,

i have csv file with 56 columns. In order not to map field after field and have 56 rows in mapper, iam using this function (mapping and replacing . with , ).

$.mapValues(x => x.replaceAll('.', ','))

but my problem is: i need to add yesterdays date as first column.

is there any chance to add column to this function or do i need to map all columns and new column will be added as first column?

thank you

1 ACCEPTED SOLUTION

koryknick
Employee
Employee

I’m not sure what the mapValues is doing in your example, but you can use extend() to add to the JSON document. In this case, you would create a new object with your “yesterday” field and extend that with the incoming object. Something like this:

{ "yesterday" : Date.now().minusDays(1).toLocaleDateString() }.extend($)

View solution in original post

1 REPLY 1

koryknick
Employee
Employee

I’m not sure what the mapValues is doing in your example, but you can use extend() to add to the JSON document. In this case, you would create a new object with your “yesterday” field and extend that with the incoming object. Something like this:

{ "yesterday" : Date.now().minusDays(1).toLocaleDateString() }.extend($)