Re: Importing Apple Cash Transactions into Quicken
barry
Member
The original thread for this was closed (https://community.quicken.com/discussion/7929653/importing-apple-cash-transactions-into-quicken), but I wanted to add another quick way of importing the items for those that don't have access to excel. This python script will do the trick.
from PyPDF2 import PdfReader
import pandas as pd
# Reload the PDF file
pdf_path = "Apple Cash Statement.pdf"
reader = PdfReader(pdf_path)
# Initialize a list to store extracted transactions
transactions = []
# Iterate over all pages and extract the relevant data
for page in reader.pages:
text = page.extract_text()
lines = text.split("\n")
for i in range(len(lines) - 1): # Iterate through pairs of lines
if "Daily Cash from Apple Card" in lines[i]:
try:
# Extract the date from the first line
date = lines[i].split()[0] # First field is the date
# Extract the amount from the second line (second field)
second_line_parts = lines[i + 1].split()
amount = float(second_line_parts[1].replace("$", "").replace(",", "")) # Second field is the amount
# Append the extracted information to the transactions list
transactions.append({
"Date": date,
"Description": "Apple Daily Cash",
"Original Description": "",
"Amount": amount,
"Transaction Type": "credit",
"Category": "",
"Account Name": "Apple Cash",
"Labels": "Apple_Daily_Cash",
"Notes": ""
})
except Exception as e:
# Handle any parsing errors gracefully
continue
# Convert the list of transactions to a DataFrame
df_transactions = pd.DataFrame(transactions)
# Save the DataFrame to a CSV file
output_csv_path = "out.csv"
df_transactions.to_csv(output_csv_path, index=False)
output_csv_path
Tagged:
0
This discussion has been closed.
Categories
- All Categories
- 56 Product Ideas
- 36 Announcements
- 223 Alerts, Online Banking & Known Product Issues
- 22 Product Alerts
- 701 Welcome to the Community!
- 671 Before you Buy
- 1.2K Product Ideas
- 53.7K Quicken Classic for Windows
- 16.3K Quicken Classic for Mac
- 1K Quicken Mobile
- 813 Quicken on the Web
- 111 Quicken LifeHub