Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

Export accounts

admin

Solved by Hugh Barnes View solution

Started by Samuele Masetto 4 years ago · 13 replies · 637 views
4 years ago

Hello,
how can I export to CSV all grav accounts?
Should I build a plugin or does a method already exist?

Thanks

4 years ago

@samuele, What would be the use case for that?

Since Grav is a flatfile based CMS, all that is needed is copying the /user/accounts folder.

4 years ago

I have a site with a thousand of accounts and my client wants to export it to CSV to verify data.

last edited 05/31/22 by Samuele Masetto
4 years ago

@samuele, AFAIK, Grav does not have the tools for this. However, conversion of YAML to CSV has quite a few search hits on the web.

4 years ago

@samuele, I don't know the plugin. Have you tried it?

4 years ago

@samuele:
do you think the data manager plugin could be useful or configured for this case?

It can because I have done this with form data. Several years ago though, may be able to dig that code out if you are interested.

I think for a one-off, I would use a conversion tool. There may be an online converter or an importer into Google Sheets or Excel. You could even write a custom PHP (Perl/Python) script. I do that when importing legacy website databases as CSV into Grav sometimes.

4 years ago

@hughbris Yes, I'm interested if you can dig that code out. I'd like to make this function available from the admin panel and before writing a plugin, I think it is better to find out standard/available options instead of writing a custom plugin...if it is possible 😉.
Thanks

👍 1
last edited 06/01/22 by Samuele Masetto
4 years ago Solution

I just took a look and it's not quite how I remembered. In fact, the CSV export is part of the Data Manager plugin by default. (It was PDF export I'd added.)

image|254x147

Accounts are not featured in Data Manager's dataset options. However, I realised that I could copy the accounts folder to user/data and then it appears as a dataset.

The problem with the CSV button is that on my Grav I get a runtime error Failed to save file /var/www/grav/tmp/data-manager/629afad6dfc81.csv/. I don't know if this is just me and I couldn't easily debug it. Would you try a CSV export and tell me if that error comes up for you? (I can see there's an issue about it.)

If we can't overcome this error, I am pretty sure we can create a hack to work around it to get your export. We don't have to store this file (where it's throwing the error), we can just serve it to the browser.

4 years ago

Cool, you worked around it. So if you copy accounts to the user/data folder, can you export user CSV?

4 years ago

Yes, in data directory I created a sym link to user/accounts and it's done 😉

👍 1
1 year ago

My error when trying to export the "Contact-form Items List" as csv file via /admin/data-manager/contact-form

TXT
RuntimeException thrown with message "Failed to save file /www/htdocs/user1/g.example.com/grav/tmp/data-manager/121212212121a.csv/"

I only got (understood) the solution by this nice stackoverflow topic:

https://stackoverflow.com/questions/71019105/i-trying-to-download-as-csv-from-grav-site-using-data-manager-but-getting-erro
🙏

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 43 1 week ago
Plugins · by Xavier, 4 weeks ago
2 53 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1179 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 47 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 72 2 months ago