Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a linebreak in csv inside concat()

I have an xmlstarlet command that looks like this:

xml sel -T-t -m /xml/path -v "concat(name,','value,',')" -n filename.xml > output.csv

It outputs like so

#output.csv
name,value,
name,value,
name,value,

I want it to look like

name,name,name,
value,value,value,

I have been focused on trying different combinations within concat:

"concat(name,'<p>'value,',')"
"concat(name,'<br />'value,',')"
"concat(name,'"<p>"'value,',')"
"concat(name,'\n'value,',')"

Am I looking at the completely wrong area?

The route I ended up taking was using a macro that transposed 8 rows into columns, within excel.

like image 590
buzzin Avatar asked Jun 16 '26 01:06

buzzin


1 Answers

Well, your concat statement explicitly concatenates names and values. It seems what you want to do is loop over the elements twice, selecting first the names and then the values.

like image 90
Michael Vehrs Avatar answered Jun 19 '26 22:06

Michael Vehrs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!