supports any separator char sequence, default is semicolon ";"
supports separator characters in the values. eg you use a ; as separator, your line may look like
blah;hello world;"foo";"foo;bar";"this is a ""string""";got it?;foo
as you can see, the values can be in "quotes". if your text uses quotes itself as in the "string"
example, they are escaped in ms-style with 2 quotes. and by using quotes we can even have your
separator inside the text (example "foo;bar").
line breaks. a csv line may spread over multiple lines using crlf in a field value.
see the checkMultiline param and the _checkMultiline() method.
missing:
option to change quote char (") to something else
example: $c =& new Bs_CsvUtil; dump($c->csvFileToArray('/some/path/file.csv'));
note I: all returned array elements are strings even if the values were numeric. note II: it may be that one array has another array-length than another. in the example above, the fruits have 4 elements while the others just have 3. this is not catched. ideally every sub-array would have 4 elements. this would have to be added when needed, maybe with another param in the function call.
Tags:
return:
(2-dim vector. it may be an empty array if there is no data.)
removeEmptyLines (default is FALSE. would remove empty lines, that is, lines where the cells are empty. white spaces count as empty aswell.)
string
{if(typeof(separator
fullPath (fullpath to the cvs file)
array
typeof(trim
array (hash or vector where the values are the csv lines)
string
typeof(removeHeader
separator (cell separator, default is ';')
string
typeof(removeEmptyLines
trim (if we should trim the cells, default is 'none', can also be 'left', 'right' or 'both'. 'none' kinda makes it faster, omits many function calls, remember that.)
bool
trim
removeHeader (default is FALSE. would remove the first line which usually is the title line.)
separator (default is ';'. set to 'auto' if you don't know, it will then be guessed. see this.guessSeparator().)
bool
trim
removeHeader (default is false, if the first line should be removed cause it's a header.)
bool
removeHeader
removeEmptyLines (if empty lines should be removed. default is false... you might want to change this. especially empty lines at the eof are annoying.)
bool
removeEmptyLines
checkMultiline (default is false, see _checkMultiline())