Create a generic data file parser that could be used with all of the file upload functions that will support .csv, .xls, .xlsx, .txt (tab-separated) files for any upload. We've had a few people request CSV uploads due to problems/limitations with Excel.
Expected Behavior
Create a generic data file parser that could be used with all of the file upload functions that will support .csv, .xls, .xlsx, .txt (tab-separated) files for any upload. We've had a few people request CSV uploads due to problems/limitations with Excel.
I've started working on this on the topic/generic_file_parser branch.
There is a new
CXGN::File::Parse
class that can be used to parse any of the supported file types into a uniform parsed data format.For example:
will return:
errors
: an array of error messages encountered during file read / parsingcolumns
: an array of the column headers in the filedata
: an array of hashes, where each array item is one row of the input filevalues
: a hash of the unique values for each columncolumn_arrays
argument, the value will be split by the delimiter (',' by default) and returned as an arrayExample Input:
Example Output: