summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_pipe.class4
1 files changed, 2 insertions, 2 deletions
diff --git a/it_pipe.class b/it_pipe.class
index 413a7b5..30e89e5 100644
--- a/it_pipe.class
+++ b/it_pipe.class
@@ -208,7 +208,7 @@ function csv($p = [])
$counts = count_chars($this->lines[0]);
$splitchar = $counts[ord("\t")] ? "\t" : ($counts[ord(";")] > $counts[ord(",")] ? ";" : ",");
$csvhead = it::replace(['^\x{FEFF}' => ''], array_shift($this->lines)); # it::replace removes utf8 byte order mark
- $schema = $p['forceschema'] ? explode(",", $p['forceschema']) : str_getcsv(trim($csvhead, "#\n "), $splitchar, '"'); # should function_exists('str_getcsv')
+ $schema = $p['forceschema'] ? explode(",", $p['forceschema']) : str_getcsv(trim($csvhead, "#\n "), $splitchar, '"', ''); # should function_exists('str_getcsv')
foreach ($schema as $idx => $col)
$schema[$idx] = it::replace(['^$' => "field$idx", '\W' => $p['fixcolnames'] ? "_" : '$0'], $col);
@@ -218,7 +218,7 @@ function csv($p = [])
foreach ($this->lines as $line)
{
- if (($cols = str_getcsv($line, $splitchar, '"')) && (count($schema) == count($cols) || $nullcols))
+ if (($cols = str_getcsv($line, $splitchar, '"', '')) && (count($schema) == count($cols) || $nullcols))
$records[] = (object)array_combine($schema, $cols + $nullcols);
else
return (array)it::error((array)$p['it_error'] + ['title' => "csv column count mismatch: " . count($schema) . " in header vs " . count($cols) . " in row", 'body' => [$schema, $cols]]);