Skip to content

Commit

Permalink
Add test and doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
phoughton committed Aug 14, 2024
1 parent 2d02a50 commit e37cb72
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,28 @@ with open("my_pacs_008_from_code.xml", "w") as xml_file:

```

### Message types?
Currently supports PACS, PAIN and CAMT messages as well as HEAD (header documents for the messages).
## Convert a CAMT.053 into an Excel file?

You can convert the entries in a CAMT.053 into a Excel file using the tools.

### Source of truth?
Currently this will extract the `Ntry` list and take all details and place them into seperate columns. It will also translate the element names intro their more meaningful English versions.

Use it like this:

```python
import pyiso20022.tools as isotools

isotools.camt053_to_excel("my_camt053_file.xml",
"my_camt053_excel_file.xlsx")
```




## Message types?
Currently pyiso20022 supports PACS, PAIN and CAMT messages as well as HEAD (header documents for the messages).


## Source of truth?

If you want the original source of truth for all things ISO 20022 schema related then check out [www.iso20022.org](https://www.iso20022.org/)
3 changes: 3 additions & 0 deletions make_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

isotools.camt053_to_excel("example_files/gs_camt/camt053_001_02.xml",
"camt053_excel.xlsx")

hed = isotools.camt053_to_df("example_files/gs_camt/camt053_001_02.xml").head()
print(hed)
5 changes: 3 additions & 2 deletions pyiso20022/tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pyiso20022.tools.camt053_to_excel import camt053_to_excel
from pyiso20022.tools.camt053_extract import camt053_to_excel
from pyiso20022.tools.camt053_extract import camt053_to_df

__all__ = [camt053_to_excel]
__all__ = [camt053_to_excel, camt053_to_df]
File renamed without changes.
34 changes: 34 additions & 0 deletions tests/tools_camt053_msgs_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pytest
from pyiso20022.tools.camt053_extract import *
import tempfile
import pandas as pd


@pytest.mark.parametrize("entry_reference, msg_id", [
("52198301", "20230928LTERMID100000312221631FT01")
])
def test_pandas_df_camt053_001_02(entry_reference, msg_id):

df = camt053_to_df("example_files/gs_camt/camt053_001_02.xml")

result = df[df['Entry Reference'] == entry_reference]["Message Identification"]

assert result.values[0] == msg_id


@pytest.mark.parametrize("entry_reference, msg_id", [
("52198301", "20230928LTERMID100000312221631FT01")
])
def test_excel_camt053_001_02(entry_reference, msg_id):

tmp_file = tempfile.NamedTemporaryFile(suffix=".xlsx")
tmp_file_name = tmp_file.name

camt053_to_excel("example_files/gs_camt/camt053_001_02.xml", tmp_file_name)

df = pd.read_excel(tmp_file_name, sheet_name='Sheet1')

tmp_file.close()

result = df[df['Entry Reference'].astype(str) == str(entry_reference)]["Message Identification"]
assert result.values[0] == msg_id

0 comments on commit e37cb72

Please sign in to comment.