Skip to content

Conversation

@sphakka
Copy link
Collaborator

@sphakka sphakka commented Apr 9, 2025

  • qif: Correct handling of date format.
  • csvtrim: much improved with CL options, detection of EOL and handling of partially broken CSV exports.

sphakka added 6 commits April 9, 2025 14:39
…zation with csvtrim

Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>
Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>
…es. +output sorting

Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>
…g txns predating the period's beginning

Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>
Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>
@sphakka
Copy link
Collaborator Author

sphakka commented Apr 9, 2025

As for the failing test "3.13, macos-latest", I guess that's due to some missing locales. Needed: fr_CH. Any advice?

Copy link
Collaborator

@jaraco jaraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this looks fine to me.

I'm not very familiar with csvtrim, and I sort-of feel like it should be moved to another project (or replaced with something like csvkit or miller). csvtrim appears to be bash-specific and thus minimally portable. That said, I can see that you've contributed to this utility before, and it only applies to this one mapping, so getting this code uncommented and fixed is useful. Let's proceed.

Copy link
Collaborator

@jaraco jaraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the ruff formatting error, but there are still failures in the tests for the mapping. Please fix.

@sphakka
Copy link
Collaborator Author

sphakka commented Jul 29, 2025

I fixed the ruff formatting error, but there are still failures in the tests for the mapping. Please fix.

Hi, thanks for all this. Actually, the failing test is on mapping 'n26', not my 'ubs-ch-fr'. I see it also on my local clone:

=================================================================================== FAILURES ===================================================================================
____________________________________________________________________ test_sample[opts30-n26-fr.csv-n26.ofx] ____________________________________________________________________

opts = ['-m', 'n26'], in_filename = 'n26-fr.csv', out_filename = 'n26.ofx', capsys = <_pytest.capture.CaptureFixture object at 0x7fcaa4db11d0>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fcaa50030e0>

    @pytest.mark.parametrize(['opts', 'in_filename', 'out_filename'], samples)
    @freezegun.freeze_time("2016-10-31 11:29:08")
    def test_sample(opts, in_filename, out_filename, capsys, monkeypatch):
        monkeypatch.setattr(csv2ofx.main, '_time_from_file', lambda path: time.time())
        arguments = [str(data / 'test' / in_filename)]
        command = list(itertools.chain(['csv2ofx'], flatten_opts(opts), arguments))
        with pytest.raises(SystemExit) as exc:
            csv2ofx.main.run(command[1:])
        # Success - exit code 0
        assert exc.value.code == 0
    
        expected = data.joinpath("converted", out_filename).read_text(encoding='utf-8')
>       assert capsys.readouterr().out == expected, (
            f"Unexpected output from {subprocess.list2cmdline(command)}"
        )
E       AssertionError: Unexpected output from csv2ofx -m n26 data/test/n26-fr.csv
E       assert 'DATA:OFXSGML...V1>\n</OFX>\n' == 'DATA:OFXSGML...V1>\n</OFX>\n'
E         
E         Skipping 638 identical leading characters in diff, use -v to show
E         Skipping 514 identical trailing characters in diff, use -v to show
E         - TEND>20250406</DTEND>
E         ?           ^^^
E         + TEND>20250729</DTEND>
E         ?           ^^^

tests/test_cli.py:148: AssertionError
=========================================================================== short test summary info ============================================================================
FAILED tests/test_cli.py::test_sample[opts30-n26-fr.csv-n26.ofx] - AssertionError: Unexpected output from csv2ofx -m n26 data/test/n26-fr.csv

I haven't touched m26 code and, sorry, have no idea about how to fix it -- my branch is ahead of upstream...

As for 'csvtrim' (I'm the author), @reubano though of integrating it (#144) through 'meza' which is fine for me. Otherwise, it may be moved out of the code base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants