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

Closed
opened 2026-05-01 02:26:03 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/5879
Author: @StephenBrown2
Created: 10/7/2025
Status: Merged
Merged: 11/5/2025
Merged by: @MatissJanis

Base: masterHead: add-csv-trim-lines


📝 Commits (10+)

  • de830d7 transactions: support skipping start and end lines when parsing CSV
  • 05320b8 types: add preference key for skipping end lines on CSV imports
  • 0b8011f ui: support separate skip start and skip end CSV settings in import modal
  • b67f73f docs: add release note about trimming footer lines in CSV imports
  • c7c93ec coderabbit.ai: Adds step attribute to number inputs
  • b636359 coderabbit nitpick
  • cdc4b9f Ensures line skip values are non-negative
  • e21a56f Updates CSV skip lines pref key
  • 5486a38 [autofix.ci] apply automated fixes
  • 3637edf Update VRT screenshots

📊 Changes

11 files changed (+75 additions, -15 deletions)

View changed files

📝 packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-Import-Transactions-import-csv-file-twice-1-chromium-linux.png (+0 -0)
📝 packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-Import-Transactions-import-csv-file-twice-2-chromium-linux.png (+0 -0)
📝 packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-Import-Transactions-import-csv-file-twice-3-chromium-linux.png (+0 -0)
📝 packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-1-chromium-linux.png (+0 -0)
📝 packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-2-chromium-linux.png (+0 -0)
📝 packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-3-chromium-linux.png (+0 -0)
📝 packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.tsx (+41 -11)
packages/loot-core/migrations/1762178745667_rename_csv_skip_lines_pref.sql (+8 -0)
📝 packages/loot-core/src/server/transactions/import/parse-file.ts (+18 -3)
📝 packages/loot-core/src/types/prefs.ts (+2 -1)
upcoming-release-notes/5879.md (+6 -0)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/5879 **Author:** [@StephenBrown2](https://github.com/StephenBrown2) **Created:** 10/7/2025 **Status:** ✅ Merged **Merged:** 11/5/2025 **Merged by:** [@MatissJanis](https://github.com/MatissJanis) **Base:** `master` ← **Head:** `add-csv-trim-lines` --- ### 📝 Commits (10+) - [`de830d7`](https://github.com/actualbudget/actual/commit/de830d783a6bf884a6099f5b8462091e8880b644) transactions: support skipping start and end lines when parsing CSV - [`05320b8`](https://github.com/actualbudget/actual/commit/05320b8542db6b69274414f73e68833c280c571a) types: add preference key for skipping end lines on CSV imports - [`0b8011f`](https://github.com/actualbudget/actual/commit/0b8011fdc6b4971fe9723fd817711ebfc77305cb) ui: support separate skip start and skip end CSV settings in import modal - [`b67f73f`](https://github.com/actualbudget/actual/commit/b67f73fc5ad2841b78d0e595c783bbda8e014e28) docs: add release note about trimming footer lines in CSV imports - [`c7c93ec`](https://github.com/actualbudget/actual/commit/c7c93ec8609959c325f08ab0cd2c2832c3b51d88) coderabbit.ai: Adds step attribute to number inputs - [`b636359`](https://github.com/actualbudget/actual/commit/b636359bc6dd995f89dc0eb2547fa8c1ab23bad8) coderabbit nitpick - [`cdc4b9f`](https://github.com/actualbudget/actual/commit/cdc4b9f97d9d22ffa0f93c4a430d43070e26cf0e) Ensures line skip values are non-negative - [`e21a56f`](https://github.com/actualbudget/actual/commit/e21a56fb971613877d2181c961727d1183f526e8) Updates CSV skip lines pref key - [`5486a38`](https://github.com/actualbudget/actual/commit/5486a38ead843e0b75044eb2e72cc404aed5f9fc) [autofix.ci] apply automated fixes - [`3637edf`](https://github.com/actualbudget/actual/commit/3637edf99ed86133aa645ba9361eea5ea2096b81) Update VRT screenshots ### 📊 Changes **11 files changed** (+75 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-Import-Transactions-import-csv-file-twice-1-chromium-linux.png` (+0 -0) 📝 `packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-Import-Transactions-import-csv-file-twice-2-chromium-linux.png` (+0 -0) 📝 `packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-Import-Transactions-import-csv-file-twice-3-chromium-linux.png` (+0 -0) 📝 `packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-1-chromium-linux.png` (+0 -0) 📝 `packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-2-chromium-linux.png` (+0 -0) 📝 `packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-3-chromium-linux.png` (+0 -0) 📝 `packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.tsx` (+41 -11) ➕ `packages/loot-core/migrations/1762178745667_rename_csv_skip_lines_pref.sql` (+8 -0) 📝 `packages/loot-core/src/server/transactions/import/parse-file.ts` (+18 -3) 📝 `packages/loot-core/src/types/prefs.ts` (+2 -1) ➕ `upcoming-release-notes/5879.md` (+6 -0) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-01 02:26:03 -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#55488