Skip to content

MarcoVando/Shortcuts-CSV-Filter-Export

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Shortcuts-CSV-Filter-Export

Purpose

This Apple Shortcut reads a CSV transaction file, extracts all rows containing the category CASH, keeps the original CSV header, and creates a new CSV file containing only CASH transactions.

The workflow is similar to a Python pandas filter:

df[df["category"] == "CASH"]

but implemented entirely inside Apple Shortcuts.

Shortcut link: https://www.icloud.com/shortcuts/8364db4cc2a544d8a000b491940050d7


Shortcut Logic

1. Select Input File

Select File
      ↓
Get Name of File

The shortcut starts by asking the user to select the original CSV file.

Example:

TR-June2026.csv

2. Prepare Output Filename

Get File Name
      ↓
Replace ".csv" with "_cash.csv"
      ↓
Set Variable: orig_filename

Example:

Input:

TR-June2026.csv

becomes:

TR-June2026_cash.csv

This variable is later used as the output filename.


3. Create Storage List

Create an empty list and initialize it:

List
(empty)

      ↓

Add orig_filename
      ↓

Set Variable: cash_list

cash_list will temporarily store the rows that will become the new CSV.


4. Split CSV into Rows

Original File
      ↓
Split Text
      ↓
Split by New Lines

The CSV is converted into a list:

[
Header row,
Transaction row 1,
Transaction row 2,
Transaction row 3
]

5. Loop Through Every CSV Row

Repeat with Each Item
        ↓
   Repeat Item = current CSV row
   Repeat Index = row number

6. Keep Header Row

The first row contains the column names.

Logic:

If Repeat Index = 1

        ↓

Add Repeat Item
to cash_list

Example:

date,category,amount,description

is always preserved.


7. Filter CASH Transactions

For all other rows:

Otherwise

      ↓

If Repeat Item contains "CASH"

      ↓

Add Repeat Item
to cash_list

Example:

Kept:

2026-06-01,CASH,100,Deposit

Ignored:

2026-06-02,TRADING,250,Stock purchase

Complete Flow Diagram

Select File
      ↓
Get Name of File
      ↓
Replace ".csv" with "_cash.csv"
      ↓
Set Variable orig_filename
      ↓
List
      ↓
Add orig_filename
      ↓
Set Variable cash_list
      ↓
Split File by New Lines
      ↓
Repeat with Each Item
      ↓
        ┌───────────────────────┐
        │ Repeat Index = 1 ?    │
        └───────────────────────┘
              ↓ Yes
        Add Header Row
        to cash_list

              ↓ No

        ┌───────────────────────┐
        │ Contains "CASH" ?     │
        └───────────────────────┘
              ↓ Yes

        Add Row
        to cash_list

              ↓

        End Repeat

      ↓

Combine cash_list
with New Lines

      ↓

Save File

Output

The shortcut generates:

TR-June2026_cash.csv

Containing:

date,category,amount,description
2026-06-01,CASH,100,Deposit
2026-06-05,CASH,50,Withdrawal

while excluding non-CASH transactions.


Notes

  • Repeat Index = 1 is used instead of a manual counter because Shortcuts already provides the row position.
  • The header is preserved so the exported file remains a valid CSV.
  • The workflow can be adapted easily for other categories by replacing "CASH" with another value such as "TRADING".

About

Apple Shortcut to read a CSV transaction file, extracts all rows containing the category CASH, keeps the original CSV header, and creates a new CSV file containing only CASH transactions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors