CSV Import delimiter

Hi

I try to import CSV from my Bank Account. Where can I set the delimiter? For now the Mapping Table shows me only one column…

Thx

Hi,

I believe the app expects a comma to be used as the delimiter.

Thx @hillel

This would be a nice feature, cause my Bank Transaction File always comes with Semicolon…

I found a description of auto-detecting feature:
https://maruan.medium.com/auto-detect-csv-enclosure-and-delimiter-in-php-b2193d34f61b

Should I make a feature request or is this function not on your wishlist at all?

Auto-detection is probably the best option. If you could please create an issue to request the feature it would be helpful.

cc @david

Yes I will do that… But not only that: I‘ve found an elegant solution, but I don’t know where to include that… Otherwise if you can assist a little, I would make a PR…

The code is:

/**
* @param string $csvFile Path to the CSV file
* @return string Delimiter
*/
public function detectDelimiter($csvFile)
{
    $delimiters = [";" => 0, "," => 0, "\t" => 0, "|" => 0];

    $handle = fopen($csvFile, "r");
    $firstLine = fgets($handle);
    fclose($handle); 
    foreach ($delimiters as $delimiter => &$count) {
        $count = count(str_getcsv($firstLine, $delimiter));
    }

    return array_search(max($delimiters), $delimiters);
}

@david can you please advise?

Hi @hillel

I think I‘ve found the right place…

I just made a new feature request and a PR with a working solution. I‘ve tested with Comma-separated and Semicolon-separated CSV-Files…

Link to the Feature Request

Link to the PR

Thx

1 Like

@checkitsedo

Thanks for the contribution, this has been merged.

1 Like