RIPE-NCC / ripe-atlas-tools

Official command-line client for RIPE Atlas
GNU General Public License v3.0
183 stars 48 forks source link

Print output as simple CSV instead of pretty print. #223

Closed cmosig closed 1 year ago

cmosig commented 3 years ago

Is there a way to get the output as csv instead of pretty-printed? For example ripe-atlas measurement-search --search "campaign:stuck_routes" --af 4 returns:


Filters:
  Search: campaign:stuck_routes
  Af: 4

Id      Type       Description                                            Status
================================================================================
b'\x1b[31m7827954 traceroute campaign:stuck_routes target:84.205.71.1               Failed\x1b[0m'
b'\x1b[33m7827955 traceroute campaign:stuck_routes target:84.205.71.1              Stopped\x1b[0m'
b'\x1b[33m7827956 traceroute campaign:stuck_routes target:84.205.71.1              Stopped\x1b[0m'
[...]
b'\x1b[33m7829765 traceroute campaign:stuck_routes target:84.205.71.1              Stopped\x1b[0m'
b'\x1b[33m7829766 traceroute campaign:stuck_routes target:84.205.71.1              Stopped\x1b[0m'
b'\x1b[33m7829767 traceroute campaign:stuck_routes target:84.205.71.1              Stopped\x1b[0m'
b'\x1b[33m7830243 traceroute campaign:stuck_routes target:84.205.71.1              Stopped\x1b[0m'
b'\x1b[33m7830244 traceroute campaign:stuck_routes target:84.205.71.1              Stopped\x1b[0m'
b'\x1b[33m7830245 traceroute campaign:stuck_routes target:84.205.71.1              Stopped\x1b[0m'
b'\x1b[33m7830246 traceroute campaign:stuck_routes target:84.205.71.1              Stopped\x1b[0m'
================================================================================
                                         Showing 50 of 423662 total measurements

A simple comma delimited csv would be nice option such that the output can be easily parsed using awk or cut. The output is especially hard to parse if it contains a probe description that is not surrounded by quotes.

chrisamin commented 1 year ago

CSV support added with bc3010be0a1b018da588d549a19b9adf3c7b5620, plus a tab format that works well with awk