diff options
author | Christian Helbling | 2017-09-29 17:27:59 +0200 |
---|---|---|
committer | Christian Helbling | 2017-09-29 17:29:46 +0200 |
commit | 44559ea5f8341f4364d2f1d6fe16754768950307 (patch) | |
tree | 4cc8bfce5fa8942c0608bdd530f758a0f4b5a86f | |
parent | 123ff76064f5b0562921491665fe3f0cf68b3196 (diff) | |
download | itools-44559ea5f8341f4364d2f1d6fe16754768950307.tar.gz itools-44559ea5f8341f4364d2f1d6fe16754768950307.tar.bz2 itools-44559ea5f8341f4364d2f1d6fe16754768950307.zip |
remove utf8 byte order mark at start of file for it_pipe::csv() so first key/column works correctly
-rw-r--r-- | it_pipe.class | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/it_pipe.class b/it_pipe.class index 8c7f92f..77ef565 100644 --- a/it_pipe.class +++ b/it_pipe.class @@ -201,7 +201,7 @@ function csv($p = []) $p = is_string($p) ? ['forceschema' => $p] : $p; $counts = count_chars($this->lines[0]); $splitchar = $counts[ord("\t")] ? "\t" : ($counts[ord(";")] > $counts[ord(",")] ? ";" : ","); - $csvhead = array_shift($this->lines); + $csvhead = it::replace(['^\x{FEFF}' => ''], array_shift($this->lines)); // it::replace removes utf8 byte order mark $cols = $p['forceschema'] ? explode(",", $p['forceschema']) : str_getcsv(trim($csvhead, "#\n "), $splitchar, '"'); # should function_exists('str_getcsv') foreach ($cols as $idx => $col) $cols[$idx] = it::replace(['^$' => "field$idx", '\W' => $p['fixcolnames'] ? "_" : '$0'], $col); |