Skip to content

Commit

Permalink
add offsetheader
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu.saison committed Sep 5, 2024
1 parent 11e18fa commit cb75174
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class AccountStatementImportSheetMapping(models.Model):
help="When this occurs please indicate the column number in the Columns section "
"instead of the column name, considering that the first column is 0",
)
offset_header = fields.Integer(
"Offset Header",
default=0,
help="Number of row to ignore until the header",
)
skip_empty_lines = fields.Boolean(
"Skip Empty Lines",
default=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ def _parse_lines(self, mapping, data_file, currency_code):
decoded_file = data_file.decode(detected_encoding)
csv_or_xlsx = reader(StringIO(decoded_file), **csv_options)
header = False

if mapping.offset_header:
for _row in range(mapping.offset_header):
next(csv_or_xlsx)

Check warning on line 174 in account_statement_import_txt_xlsx/models/account_statement_import_sheet_parser.py

View check run for this annotation

Codecov / codecov/patch

account_statement_import_txt_xlsx/models/account_statement_import_sheet_parser.py#L174

Added line #L174 was not covered by tests

if not mapping.no_header:
if isinstance(csv_or_xlsx, tuple):
header = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
name="offset_row"
attrs="{'invisible': [('no_header', '=', True)]}"
/>
<field
name="offset_header"
attrs="{'invisible': [('no_header', '=', True)]}"
/>
</group>
<group
attrs="{'invisible': [('debit_credit_column', '=', False)]}"
Expand Down

0 comments on commit cb75174

Please sign in to comment.