MadWalnut / firefly-iii-dkb-csv-fix

Prepares a CSV file from DKB for import into Firefly III
Other
8 stars 0 forks source link

New DKB CSV export #2

Closed Aypac closed 6 months ago

Aypac commented 11 months ago

Hey,

thanks for this script. It used to work well. However, it looks like DKB changed their CSV export and the script stopped working.

Cheers, René

MadWalnut commented 11 months ago

Hi, can you give this updated version a go?

new_format_test.zip

I had to remove support for the credit card statement though because I do not own a DKB credit card anymore and therefore I can't get a sample file. I'm happy to re-implement it though if you can provide me one. You can of course redact all your personal information. I also don't need all transactions except maybe one or two (but here again please replace your personal information with dummy values).

dmasur commented 8 months ago

Sorry no: PS C:\Users\xxx\Downloads\new_format_test\build\win-x64> .\FireflyFixTransactionReportDKB.exe .\15-01-2024_Umsatzliste_Girokonto_DE131203000000xxx.csv Unexpected start of given file. Is this file a DKB export?

Sums123 commented 7 months ago

Hi, can you give this updated version a go?

new_format_test.zip

I had to remove support for the credit card statement though because I do not own a DKB credit card anymore and therefore I can't get a sample file. I'm happy to re-implement it though if you can provide me one. You can of course redact all your personal information. I also don't need all transactions except maybe one or two (but here again please replace your personal information with dummy values).

image

MadWalnut commented 7 months ago

Which version of the online banking are you using, new (banking.dkb.de) or old (www.ib.dkb.de)? This script has been written for the old version and I don't think it makes sense to update it any further because that old banking will be gone for good soon.

The new version requires way less work before importing. Basically only stripping the first 4 lines (no idea why they decided to violate CSV standards once again in this new version...). No more weird codepages. At least for me that works fine using the import configuration from #4.

Can you confirm this? Just open the export from the new banking with Notepad and remove everything until "Buchungsdatum". This is what the first line should start with.

If that works for you, I will write a mini-version of this script, which just strips those first 4 lines. Maybe in a new repo or directly as a code-snippet here. Then we can keep this current version as the old legacy script in case someone wants to import old CSVs in the future.

@Sums123 Understandable you find that concerning. I can only say that it is a false positive. There is no need to execute the pre-compiled version though if you don't trust me (fair enough). Inside the ZIP file there is also the source code which you can look at and run with dotnet run.

MadWalnut commented 6 months ago

The new format requires significantly less changes (basically only removing the first 4 lines of the export) as discussed in #4. Any small script like these from ChatGPT could handle this.

Bash:

#!/bin/bash

# Check if a filename is provided as an argument
if [ "$#" -eq 0 ]; then
    echo "Usage: $0 <filename>"
    exit 1
fi

# Assign the filename to a variable
filename="$1"

# Check if the file exists
if [ ! -f "$filename" ]; then
    echo "Error: File not found - $filename"
    exit 1
fi

# Use sed to remove the first 4 lines and overwrite the file
sed -i '1,4d' "$filename"

echo "First 4 lines removed from $filename"

PowerShell:

# Check if a filename is provided as an argument
if ($args.Count -eq 0) {
    Write-Host "Usage: .\Remove-First4Lines.ps1 <filename>"
    exit 1
}

# Assign the filename to a variable
$filename = $args[0]

# Check if the file exists
if (-not (Test-Path $filename -PathType Leaf)) {
    Write-Host "Error: File not found - $filename"
    exit 1
}

# Read the content of the file, excluding the first 4 lines
$content = Get-Content $filename | Select-Object -Skip 4

# Write the modified content back to the file
$content | Set-Content $filename

Write-Host "First 4 lines removed from $filename"

I do not think it is worth maintaining this repo anymore for such a simple task. The current code should still work if you need to import some old files you may have or until the old banking is shut down for good.

I have opened a pull request in the main repo for new users with an updated README and .json.