@@ -19,7 +19,6 @@ |
||
19 | 19 | use CSVelte\Contract\Readable; |
20 | 20 | use CSVelte\Contract\Writable; |
21 | 21 | use CSVelte\Contract\Seekable; |
22 | - |
|
23 | 22 | use CSVelte\Exception\NotYetImplementedException; |
24 | 23 | |
25 | 24 | /** |
@@ -14,11 +14,9 @@ |
||
14 | 14 | namespace CSVelte; |
15 | 15 | |
16 | 16 | use CSVelte\Contract\Streamable; |
17 | - |
|
18 | 17 | use CSVelte\Table\Row; |
19 | 18 | use CSVelte\Table\HeaderRow; |
20 | 19 | use CSVelte\Reader\FilteredIterator as FilteredReader; |
21 | - |
|
22 | 20 | use CSVelte\Exception\EndOfFileException; |
23 | 21 | |
24 | 22 | use function |
@@ -19,7 +19,6 @@ |
||
19 | 19 | use CSVelte\Contract\Readable; |
20 | 20 | use CSVelte\Contract\Writable; |
21 | 21 | use CSVelte\Contract\Seekable; |
22 | - |
|
23 | 22 | use CSVelte\Exception\NotYetImplementedException; |
24 | 23 | |
25 | 24 | /** |
@@ -292,20 +292,20 @@ discard block |
||
292 | 292 | throw new TasterException("quoteChar and delimiter cannot be determined", TasterException::ERR_QUOTE_AND_DELIM); |
293 | 293 | } |
294 | 294 | |
295 | - /** |
|
296 | - * Take a list of likely delimiter characters and find the one that occurs |
|
297 | - * the most consistent amount of times within the provided data. |
|
298 | - * |
|
299 | - * @param string $eol The character(s) used for newlines |
|
300 | - * @return string One of four Flavor::QUOTING_* constants |
|
301 | - * @see Flavor for possible quote style constants |
|
302 | - * @todo Refactor this method--It needs more thorough testing against a wider |
|
303 | - * variety of CSV data to be sure it works reliably. And I'm sure there |
|
304 | - * are many performance and logic improvements that could be made. This |
|
305 | - * is essentially a first draft. |
|
306 | - * @todo Can't use replaceQuotedSpecialChars rather than removeQuotedStrings |
|
307 | - * because the former requires u to know the delimiter |
|
308 | - */ |
|
295 | + /** |
|
296 | + * Take a list of likely delimiter characters and find the one that occurs |
|
297 | + * the most consistent amount of times within the provided data. |
|
298 | + * |
|
299 | + * @param string $eol The character(s) used for newlines |
|
300 | + * @return string One of four Flavor::QUOTING_* constants |
|
301 | + * @see Flavor for possible quote style constants |
|
302 | + * @todo Refactor this method--It needs more thorough testing against a wider |
|
303 | + * variety of CSV data to be sure it works reliably. And I'm sure there |
|
304 | + * are many performance and logic improvements that could be made. This |
|
305 | + * is essentially a first draft. |
|
306 | + * @todo Can't use replaceQuotedSpecialChars rather than removeQuotedStrings |
|
307 | + * because the former requires u to know the delimiter |
|
308 | + */ |
|
309 | 309 | protected function lickDelimiter($eol = "\n") |
310 | 310 | { |
311 | 311 | $frequencies = []; |
@@ -382,16 +382,16 @@ discard block |
||
382 | 382 | * which one has the best distribution, return that one. |
383 | 383 | */ |
384 | 384 | |
385 | - $decision = $dups->get($max); |
|
386 | - try { |
|
387 | - return $this->guessDelimByDistribution($decision, $eol); |
|
388 | - } catch (TasterException $e) { |
|
389 | - // if somehow we STILL can't come to a consensus, then fall back to a |
|
390 | - // "preferred delimiters" list... |
|
391 | - foreach ($this->delims as $key => $val) { |
|
385 | + $decision = $dups->get($max); |
|
386 | + try { |
|
387 | + return $this->guessDelimByDistribution($decision, $eol); |
|
388 | + } catch (TasterException $e) { |
|
389 | + // if somehow we STILL can't come to a consensus, then fall back to a |
|
390 | + // "preferred delimiters" list... |
|
391 | + foreach ($this->delims as $key => $val) { |
|
392 | 392 | if ($delim = array_search($val, $decision)) return $delim; |
393 | - } |
|
394 | - } |
|
393 | + } |
|
394 | + } |
|
395 | 395 | } |
396 | 396 | return $delims |
397 | 397 | ->sort() |
@@ -450,8 +450,8 @@ discard block |
||
450 | 450 | })->map(function($dists) { |
451 | 451 | return $dists->average(); |
452 | 452 | })->sort() |
453 | - ->reverse() |
|
454 | - ->getKeyAtPosition(0)]; |
|
453 | + ->reverse() |
|
454 | + ->getKeyAtPosition(0)]; |
|
455 | 455 | } catch (Exception $e) { |
456 | 456 | throw new TasterException("delimiter cannot be determined by distribution", TasterException::ERR_DELIMITER); |
457 | 457 | } |