Skip to content

Commit

Permalink
Fix csv file recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-done committed Apr 9, 2024
1 parent b1058a7 commit 87ae0a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Code/Converters/CsvConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private static function csvToArray($content)

$csv2 = [];
foreach ($csv as $row) {
if (!isset($row[0]) || !isset($row[1])) {
if ($row[0] == '' && !isset($row[1])) { // empty line
continue;
}
if (trim($row[0]) === '' && trim($row[1]) === '') {
Expand Down
9 changes: 9 additions & 0 deletions tests/formats/CsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,13 @@ public function testSpeakerInFrontAndEmptyLines()

$this->assertInternalFormatsEqual($expected_internal_format, $actual_internal_format);
}

public function testDifferentElementCountShouldntBeInterpretedAsCsv()
{
$csv = 'Start,End,Text
hi
3740.476,3742.501,"Very good, Lieutenant."';
$converter = Helpers::getConverterByFileContent($csv);
$this->assertTrue(get_class($converter) !== CsvConverter::class, get_class($converter));
}
}

0 comments on commit 87ae0a9

Please sign in to comment.