Forum Discussion
So, the site I found fixed the issue with my text for the description field getting spread incorrectly across three columns, but now I have roughly 250 rows out of about 7000 rows where the description is messed up, with characters like apostrophes displayed incorrectly on the csv output.
Issues:
- Apostrophe’s are incorrectly output, example: women’s becomes women’s
- “bad” and “wild” becomes “bad†and “wildâ€
- An em-dash in a text like P—GRK becomes P—GRK
Can someone help me with this?
New Note: I discovered if I open my csv in notepad++ the characters all appear to be correct and not messed up as above. So, I really don’t know what to do now.
Can someone please help me with this?
Hi @vincenr
Good day, this are extended characters/ascii code which maybe be viewed in excel or other app as special character
So, what do you want to do with this characters?
Here are some options that you can do (1) replace the extended characters with the regular ones or (2) just remove all those characters
$the_text_description.replace(/”|“|‘|’|–|—/g, m=> match m { '”'=> '"', '“'=> '"', "‘"=> "'", "’"=> "'", "—"=> "-", "–"=> "-" })
or you can also totally removed those characters
$the_text_description.replace(/”|“|‘|’|–|—/g, '')
Thanks,
MM
You can use merge function too.
Community_Example_2021_05_11.slp (3.5 KB)
$group.map(x=>x.merge({“sum”:$group.map(item => item.key2).reduce((accum, currentValue) => accum + currentValue)}))
@Tanmay_Sarkar - I haven’t put an example together, but you should be able to do this with a combination of map() and reduce() functions. Looking at the full spec of the Array.map() function, you can access the array as one of the parameters:
- Tanmay_Sarkar5 years agoNew Contributor III
@koryknick Thanks a lot, eventually map and merge function helped.
- bojanvelevski5 years agoValued Contributor
Hi @Tanmay_Sarkar,
You can also use Apache Velocity within JSON Generator. Here is the script:
#set($sum = 0)
#foreach ($field in $group)
#set($sum=$sum+$field.key2)
#end#foreach($field in $group)
#set($dummy = $field.put(“sum”,$sum))
#end{“group”:$group}
Regards,
Bojan- Tanmay_Sarkar5 years agoNew Contributor III
@bojanvelevski Thanks a lot, I never realized Apache Velocity can be used within JSON generator in such a way, this would come in handy in future.
- Tanmay_Sarkar5 years agoNew Contributor III
This expression helped for now:
jsonPath($, “group[*]”).map(item => item.key2).reduce((prev, next) => prev + next)Mapped this to field “sum” and pushed it into the array.
Is there any other way as well to achieve this?
- Tanmay_Sarkar5 years agoNew Contributor III
@skatpally Thanks a lot, this worked effortlessly.