mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 00:36:38 +00:00
@@ -1170,7 +1170,7 @@ class Csv {
|
||||
|
||||
$data = fread($fh, filesize($file));
|
||||
fclose($fh);
|
||||
return $data;
|
||||
return rtrim($data, "\r\n");
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
22
tests/example_files/multiple_empty_lines.csv
Normal file
22
tests/example_files/multiple_empty_lines.csv
Normal file
@@ -0,0 +1,22 @@
|
||||
ID,dID,createdAt,else1,else2,else3,else4,else5,user,else6,else7,else8,else9,else10,else11,else12,else13,else14,else15,else16,else17,else18,else19,else20,else21,else22,else23,else24,else25,else26,else27,else28,else29,else30,else31,else32,else33,else34,else35,else36,else37,else38
|
||||
418,0,2017-05-16,,,2018-01-22,22.01.2018 10:00:09,,admin,Ja,,10001,Abweichung,,10001,v1,1,ddd,100,1000,,HH,,v1,0,401,1,2,H1,,-1,10,1,111,Ja,2017-01-01,,12,0,11109,HH-100,default
|
||||
419,0,2017-05-16,,,2017-05-16,14.07.2017 09:58:09,,admin,Ja,,,Abweichung,,10002,v2,1,ddd,200,500,DD,DD,,v2,1,402,2,4,H2,,-2,100,1,1111,Ja,2017-01-01,1,13,1,11109,DD-200,default
|
||||
438,0,2017-05-16,,,2017-05-16,14.07.2017 09:58:29,,admin,Ja,,10021,Abweichung,,10021,v3,4,ddd,300,400,DD,DD,,v3,0,421,1,,H3,,-1,106,1,111,Ja,2017-05-08,,2,1,11109,DD-300,default
|
||||
440,0,2017-05-16,,,,14.07.2017 09:58:53,,admin,Ja,,,Alt,,10023,v4,3,,400,500,BE,DD,,v4,1,423,3,,H4,,-3,143,1,1111,Ja,2017-01-01,1,33,1,11108,BE-400,default
|
||||
441,0,2017-05-16,,,,14.07.2017 09:59:19,,admin,Ja,,,Fehlt,,10024,v5,3,,500,,BE,,,v5,2,424,4,,H5,,0,1435,0,111,Ja,2017-01-01,,12,1,0,BE-500,default
|
||||
442,0,2017-05-16,,,,14.07.2017 10:00:46,,admin,Ja,,,Neu,,10025,v6,3,,100,,DD,,,v6,435,425,1,,H6,,0,10,0,1111,Ja,2017-01-01,,102,1,0,DD-100,default
|
||||
443,0,2017-05-16,,,2017-07-04,14.07.2017 10:01:12,,admin,Ja,,,OK,,10026,v7,3,,200,200,DD,DD,,v7,32,426,2,2,H7,,0,100,0,111,Ja,2017-01-01,,77,1,0,DD-200,default
|
||||
444,0,2017-05-16,,,,14.07.2017 10:02:13,,admin,Ja,,,Fehlt,,10027,v8,3,,300,,BE,,,v8,45,427,3,,H8,,0,200,0,1111,Ja,2017-01-01,,44,3,0,BE-300,default
|
||||
445,0,2017-05-16,,,,14.07.2017 10:02:38,,admin,Ja,,,Fehlt,,10028,v9,3,,100,,BE,,,v9,45,428,4,,H9,,0,400,0,111,Ja,2017-01-01,,44,1,0,BE-100,default
|
||||
446,0,2017-05-16,,,,14.07.2017 10:03:01,,admin,Ja,,,Fehlt,,10029,v10,3,,,400,,DD,,v10,45,429,,,H10,,0,1124,0,1111,Ja,2017-01-01,,89,1,0,,default
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -126,6 +126,25 @@ class ParseTest extends TestCase {
|
||||
], $aCity);
|
||||
}
|
||||
|
||||
public function testWithMultipleNewlines() {
|
||||
$this->csv->auto(__DIR__ . '/../example_files/multiple_empty_lines.csv');
|
||||
$aElse9 = array_column($this->csv->data, 'else9');
|
||||
|
||||
/** @noinspection SpellCheckingInspection */
|
||||
$this->assertEquals([
|
||||
'Abweichung',
|
||||
'Abweichung',
|
||||
'Abweichung',
|
||||
'Alt',
|
||||
'Fehlt',
|
||||
'Neu',
|
||||
'OK',
|
||||
'Fehlt',
|
||||
'Fehlt',
|
||||
'Fehlt',
|
||||
], $aElse9);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSepRowAutoDetection
|
||||
*/
|
||||
@@ -217,8 +236,7 @@ class ParseTest extends TestCase {
|
||||
*
|
||||
* @return mixed Method return.
|
||||
*/
|
||||
private function invokeMethod(&$object, $methodName, array $parameters = array())
|
||||
{
|
||||
private function invokeMethod(&$object, $methodName, array $parameters = array()) {
|
||||
$reflection = new \ReflectionClass(get_class($object));
|
||||
$method = $reflection->getMethod($methodName);
|
||||
$method->setAccessible(true);
|
||||
|
||||
Reference in New Issue
Block a user