Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CSV export alongisde text/json #1365

Open
Justinzobel opened this issue Apr 17, 2023 · 7 comments
Open

Add CSV export alongisde text/json #1365

Justinzobel opened this issue Apr 17, 2023 · 7 comments

Comments

@Justinzobel
Copy link

What is the problem this feature would solve? Please describe.
I'm always frustrated when I want to work with the data exported from doctl and I can't output it in a basic CSV output that is easy to parse in many scripts.

Describe the solution you'd like
CSV output

Additional context
None

@Justinzobel
Copy link
Author

Any chance of this?

@MrCuPper
Copy link

MrCuPper commented Jan 8, 2024 via email

@Justinzobel
Copy link
Author

The point is to have CSV as an output option, that is all. Any chance of it being implemented is the question.

@MrCuPper
Copy link

MrCuPper commented Jan 8, 2024 via email

@danaelhe
Copy link
Member

danaelhe commented Jan 8, 2024

Hi there and thank you for bubbling this back up!

I've used third party tools such as json2csv to accomplish this. Something like:
doctl compute ssh-key ls -o json | json2csv will output a csv that I was able to cleanly import into an excel sheet. Would that work for you?

@Justinzobel
Copy link
Author

I haven't tried json2csv but if that can be integrated into doctl that would be great. I'm trying to get a list of snapshots via compute snapshot list --no-header --format=ID,Name,CreatedAt,ResourceType,Size so I can see which ones I need to clean up, etc.

@danaelhe
Copy link
Member

Oh yes, I was able to do that with json2csv like this:

doctl compute snapshot list --no-header --format=ID,Name,CreatedAt,ResourceType,Size -o json | json2csv
"id","name","resource_type","regions","min_disk_size","size_gigabytes","created_at"
"811111113","ubuntu-18.04-minimal","droplet","[""nyc3""]",15,0.17,"2021-04-16T17:05:33Z"

This wouldn't be a straightforward feature to integrate in doctl as that logic is baked into the Go CLI package we use, Cobra. Since there are numerous options of cli tools that can convert the outputted JSON into a CSV, we consider that a viable workaround in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants