inputformat
Input file format definitions.
Classes¶
GetInputFormats ¶
Bases: Action
Argparse action for the format argument. Adapted from this Stack Overflow answer.
Attributes:
Name | Type | Description |
---|---|---|
input_formats |
Dict[str, InputFormat]
|
Maps format names to values. |
Source code in src/xlbudget/inputformat.py
InputFormat ¶
Bases: NamedTuple
Specifies the format of the input file.
Attributes:
Name | Type | Description |
---|---|---|
header |
int
|
The 0-indexed row of the header in the input file. |
names |
List[str]
|
The column names. |
usecols |
List[int]
|
The first len( |
ignores |
List[str]
|
Ignore transactions that contain with these regex patterns. |
pre_processing |
Callable
|
The function to call before |
post_processing |
Callable
|
The function to call after |
sep |
str
|
The separator. |
Source code in src/xlbudget/inputformat.py
Functions¶
bmo_acct_web_post_processing ¶
Creates the "Amount" column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
pd.DataFrame
|
The dataframe to process. |
required |
Returns:
Type | Description |
---|---|
pd.DataFrame
|
A[n] |
Source code in src/xlbudget/inputformat.py
bmo_cc_adobe_pre_processing ¶
Create CSV from input with each element on a new line.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_input |
Optional[str]
|
The file to process, if |
required |
year |
str
|
The year of all transactions. |
required |
Returns:
Type | Description |
---|---|
io.StringIO
|
A[n] |
Source code in src/xlbudget/inputformat.py
bmo_cc_web_post_processing ¶
Formats the "Money in/out" column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
pd.DataFrame
|
The dataframe to process. |
required |
Returns:
Type | Description |
---|---|
pd.DataFrame
|
A[n] |
Source code in src/xlbudget/inputformat.py
parse_input ¶
Parses an input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
Optional[str]
|
The path to the input file, if None parse from stdin. |
required |
format |
InputFormat
|
The input format. |
required |
year |
Optional[str]
|
The year of all transactions. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If input contains duplicate transactions. |
Returns:
Type | Description |
---|---|
pd.DataFrame
|
A[n] |