[PR #5879] Add option to trim lines from CSV imports #20547

Closed
opened 2026-04-14 21:40:05 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/actualbudget/actual/pull/5879

State: closed
Merged: Yes


I frequently import statements from my bank that also include footers of "garbage" non-transactional information, so I would like to be able to trim those lines during import as well as skip the top lines.

Currently, attempting to import will only gather column headers from the columns with data in every row, so in this case, the Transaction ID. This PR fixes that by also ignoring the last broken rows and allowing an import to succeed.

This also stores the preference like the others on a per-account basis.

Example statement.csv

NOTE: I did combine the two selectors to the same row in 6c782945185f1ed8ae0a62cee452a5ea3eb13403, which I can easily undo if desired.

Outdated Screenshot: image

Copilot Summary:

This pull request adds support for trimming lines from the end of CSV files during transaction import, alongside the existing option to skip lines from the start. The changes update both the UI and backend logic to allow users to specify how many lines to skip at the beginning and trim from the end, and ensure these preferences are saved and used during parsing.

CSV Import Enhancements:

  • Added a new trimLines option to the import modal UI, allowing users to specify the number of lines to trim from the end of the CSV file. This is reflected in both state management and the input controls. [1] [2]
  • Updated the UI label for skipping lines to "Lines to skip" for clarity, and ensured that both skip and trim values are passed to the parsing logic whenever the relevant inputs change. [1] [2] [3]
  • Ensured that the trimLines preference is saved per account, similar to other import preferences.

Backend Parsing Logic:

  • Extended the ParseFileOptions type and getParseOptions helper to include the new trimLines property, passing it through all relevant function calls. [1] [2]
  • Updated the CSV parsing function to remove the specified number of lines from the end of the file before processing, using both skipLines and trimLines options.
**Original Pull Request:** https://github.com/actualbudget/actual/pull/5879 **State:** closed **Merged:** Yes --- I frequently import statements from my bank that also include footers of "garbage" non-transactional information, so I would like to be able to trim those lines during import as well as skip the top lines. Currently, attempting to import will only gather column headers from the columns with data in every row, so in this case, the Transaction ID. This PR fixes that by also ignoring the last broken rows and allowing an import to succeed. This also stores the preference like the others on a per-account basis. Example [statement.csv](https://github.com/user-attachments/files/22752809/statement.csv) NOTE: I did combine the two selectors to the same row in 6c782945185f1ed8ae0a62cee452a5ea3eb13403, which I can easily undo if desired. <details><summary>Outdated Screenshot:</summary> <img width="271" height="200" alt="image" src="https://github.com/user-attachments/assets/29289b49-5b2c-4ae2-ab4b-8a6985da87a9" /> </details> ## Copilot Summary: This pull request adds support for trimming lines from the end of CSV files during transaction import, alongside the existing option to skip lines from the start. The changes update both the UI and backend logic to allow users to specify how many lines to skip at the beginning and trim from the end, and ensure these preferences are saved and used during parsing. **CSV Import Enhancements:** * Added a new `trimLines` option to the import modal UI, allowing users to specify the number of lines to trim from the end of the CSV file. This is reflected in both state management and the input controls. [[1]](diffhunk://#diff-8e5b688cd46976e291e6b960ad3bdce1b28cc399714079c4d290b0515a228dd1R203-R205) [[2]](diffhunk://#diff-8e5b688cd46976e291e6b960ad3bdce1b28cc399714079c4d290b0515a228dd1R1037-R1057) * Updated the UI label for skipping lines to "Lines to skip" for clarity, and ensured that both skip and trim values are passed to the parsing logic whenever the relevant inputs change. [[1]](diffhunk://#diff-8e5b688cd46976e291e6b960ad3bdce1b28cc399714079c4d290b0515a228dd1L1017-R1024) [[2]](diffhunk://#diff-8e5b688cd46976e291e6b960ad3bdce1b28cc399714079c4d290b0515a228dd1R1037-R1057) [[3]](diffhunk://#diff-8e5b688cd46976e291e6b960ad3bdce1b28cc399714079c4d290b0515a228dd1R1076) * Ensured that the `trimLines` preference is saved per account, similar to other import preferences. **Backend Parsing Logic:** * Extended the `ParseFileOptions` type and `getParseOptions` helper to include the new `trimLines` property, passing it through all relevant function calls. [[1]](diffhunk://#diff-2f47313fe6474d29d6edd6cd6d7a60341b887238d5fbc66be1b122eb0c51f9e1R67) [[2]](diffhunk://#diff-8e5b688cd46976e291e6b960ad3bdce1b28cc399714079c4d290b0515a228dd1L1169-R1199) * Updated the CSV parsing function to remove the specified number of lines from the end of the file before processing, using both `skipLines` and `trimLines` options.
GiteaMirror added the pull-request label 2026-04-14 21:40:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#20547