TomWright / dasel

Select, put and delete data from JSON, TOML, YAML, XML and CSV files with a single tool. Supports conversion between formats and can be used as a Go package.
https://daseldocs.tomwright.me
MIT License
6.73k stars 126 forks source link

XML output broken, CSV output column swapped #417

Open rickhg12hs opened 1 month ago

rickhg12hs commented 1 month ago

Describe the bug

-w xml does not produce desired output.

-w csv reorders columns.

To Reproduce Steps to reproduce the behavior:

$ go version
go version go1.22.4 linux/amd64
$ ~/go/bin/dasel --version
dasel version development-v2.8.1
$ cat thrust.csv 
Time,Thrust,Source
0,0,eng
0.000,0.51,eng
0.002,0.051,sim
0.004,0.152,sim
$ ~/go/bin/dasel -r csv -w csv -f thrust.csv 
Source,Thrust,Time
eng,0,0
eng,0.51,0.000
sim,0.051,0.002
sim,0.152,0.004
$ ~/go/bin/dasel -r csv -w json -f thrust.csv 
[
  {
    "Time": "0",
    "Thrust": "0",
    "Source": "eng"
  },
  {
    "Time": "0.000",
    "Thrust": "0.51",
    "Source": "eng"
  },
  {
    "Time": "0.002",
    "Thrust": "0.051",
    "Source": "sim"
  },
  {
    "Time": "0.004",
    "Thrust": "0.152",
    "Source": "sim"
  }
]
$ ~/go/bin/dasel -r csv -w xml -f thrust.csv 
[0xc000303180 0xc0003031e0 0xc000303220 0xc000303280]
$ ~/go/bin/dasel -r csv -w xml -f thrust.csv 
[0xc0003ba060 0xc0003ba0a0 0xc0003ba0e0 0xc0003ba140]
$ ~/go/bin/dasel -r csv -w xml -f thrust.csv 
[0xc00029a2a0 0xc00029a2e0 0xc00029a320 0xc00029a3a0]

Expected behavior

-w xml should produce valid XML.

-w csv should not reorder CSV columns.

Desktop (please complete the following information):

TomWright commented 1 month ago

Thanks for raising these issues. I'll address them ASAP