Planning CSV output format
Posted by mholmes on 01 Sep 2010 in Activity log
Both JW and JS-R want output that can be loaded or pasted into a spreadsheet, so that's my next priority. This is how I envisage doing it:
- The current Search button will be accompanied by a second button, for retrieving a CSV file. Perhaps the caption of Search should be changed to something else too, so it's clear that they both search, but they retrieve different things.
- The second button should submit the same search, to the
get_search_results.php
file, but with a differentreqType
parameter ('csv' as opposed to 'ajax'). get_search_results.php
reads that parameter and sends the appropriate mime type header; then proceeds as normal, except that it ignores thefirstRec
andrecsToDisplay
parameters (CSV searches retrieve the entire set that matches the search), and instead of callingMdhRecordList::writeAsTable
, it calls awriteAsCSV
method (yet to be coded).
Before I start, I need to figure out all the rules and gotchas for CSV files which can have large text fields, as well as embedded quotes, and I need to determine how to write text in UTF-8 and ensure that spreadsheet programs can read UTF-8 CSV files.