Rclone rc core/stats output csv format

Sorry for not following the template, but is there any way for rclone rc commands to output something else than json? It's really really hard to parse it on command line

for i in {3,4,5,6,8}; do rclone rc core/stats --rc-user USER --rc-pass PASS --rc-addr :557$i; done | jq '. | join(",")' | column -ts, | b ###convert json to csv

but the above command still doesn't output headers. Csv format would make this so much easier.

If there are other ways to interface with rclone's remote control please let me know. Again, sorry about the template.

There is no csv rclone rc output.

csv is useful when data is flat and tabular but rc output is not - hence json is natural format to output I think.

It is theoretical question what is easier to process.. both formats are very well supported by all programming languages.

Shell scripts are always extremely limited for more complex data processing tasks - IMO if you face such issues you should employ some language more suitable for this task.

No worries, for completeness after hours of trial and error it turned out that jq, column and batcat can be used to format json coming from the above rclone rc command including the headers:

for i in {3,4,5,6,8}; do rclone rc core/stats --rc-user USER --rc-pass PASS --rc-addr :557$i; done | jq -sr '(.[0] | keys), .[] | join(",")' | column -ts,

to print a fairly readable table:

UPDATE: someone suggested to use miller instead and it seems to be even easier (e.g. mlr --j2c cat instead of this jq -sr '(.[0] | keys), .[] | join(",")')

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.