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:
parent
26a4198cbe
commit
d9e6d5149b
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user