Textarea export in CSV format

Textarea export in CSV format

by pitou col -
Number of replies: 3

Hello

I want to export my database. I have some textarea where users can put any text. 

But when exporting the database in CSV, I've get all the html codes, like <p>, <h1>, <br/> in the fields. 

Is there a way to avoid exporting that ?

Thank you.

Average of ratings: -
In reply to pitou col

Re: Textarea export in CSV format

by William Lu -
Picture of Particularly helpful Moodlers
As far as I know, no, sorry.
The .csv file is not reader-friendly anyway.
You may have to work on your spreadsheet to remove all un-readable content, like < p > and < / p >.
In reply to pitou col

Re: Textarea export in CSV format

by Don Hinkelman -
Picture of Particularly helpful Moodlers Picture of Plugin developers

I used the Database module to export data for the first time last week. I was shocked the Export data was so unusable. Not only odd codes as shown above, but also unreadable dates, which I have learned require a complex excel formula to convert into actual dates. These issues are not geeky inconveniences, but real bugs because normal teachers cannot use the Database module, and cannot rely on its output. Are there issues on the Tracker where we can vote to have these changed?

Average of ratings: Useful (1)
In reply to Don Hinkelman

Re: Textarea export in CSV format

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Don't know if there is a tracker issue for this. I just took a quick look at the code for the database export and I think it would require a good bit of work to implement changes needed to give a human readable date/time from the data in date fields, and also to strip out the HTML tags from text fields.
In /data/lib.php, function data_get_exportdata($dataid, $fields, $selectedfields, $currentgroup=0, $context=null, $userdetails=false, $time=false, $approval=false, $tags = false), the SQL would need to be worked on as right now it does not consider the field type at all. It just gets raw content. The content and field type are kept in two totally different tables.
You would need the code rewritten to also get the field type, then "change/fix as needed" the raw data_content to, clean the contents of text fields, and convert the Unix time in date fields. You would also need a new setting for how you want the date/time formatted, as not all countries do it the same way.
It's a shame Moodle participation in the Google Summer of Code is canceled. This would be one of those very nice to have, easily achieved projects.
Average of ratings: Useful (1)