1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 14:12:44 +01:00

Fixes for delimiter search

This commit is contained in:
David Bomba 2023-03-04 11:53:09 +11:00
parent 26a4198cbe
commit d9e6d5149b
2 changed files with 19 additions and 4 deletions

View File

@ -163,10 +163,19 @@ class ImportController extends Controller
$bestDelimiter = ' ';
$count = 0;
foreach ($delimiters as $delimiter) {
if (substr_count($csvfile, $delimiter) > $count) {
// if (substr_count($csvfile, $delimiter) > $count) {
// $count = substr_count($csvfile, $delimiter);
// $bestDelimiter = $delimiter;
// }
if (substr_count(strstr($csvfile,"\n",true), $delimiter) > $count) {
$count = substr_count($csvfile, $delimiter);
$bestDelimiter = $delimiter;
}
}
return $bestDelimiter;
}

View File

@ -123,14 +123,20 @@ class BaseImport
public function detectDelimiter($csvfile)
{
$delimiters = [',', '.', ';'];
$bestDelimiter = ' ';
$delimiters = [',', '.', ';', '|'];
$bestDelimiter = ',';
$count = 0;
foreach ($delimiters as $delimiter) {
if (substr_count($csvfile, $delimiter) > $count) {
// if (substr_count($csvfile, $delimiter) > $count) {
// $count = substr_count($csvfile, $delimiter);
// $bestDelimiter = $delimiter;
// }
if (substr_count(strstr($csvfile,"\n",true), $delimiter) > $count) {
$count = substr_count($csvfile, $delimiter);
$bestDelimiter = $delimiter;
}
}
return $bestDelimiter;
}