Mutual Fund CAS PDF Statement Parser
A Python tool/library that extracts data from Consolidated Account Statement (CAS) PDFs (https://github.com/ukkit/processCASpdf) — tested with KFintech — into CSV, DataFrame, JSON, or a list of dictionaries.
Requirements
- Python >= 3.9
- uv package manager
- Internet connection (fetches AMFI scheme data on each run)
Installation
git clone https://github.com/ukkit/processCASpdf.git
cd processCASpdf
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync
Usage
from processCASpdf import ProcessPDF
pdf = ProcessPDF("CAS_statement.pdf", password="your_pdf_password")
filename(required) - Path to the CAS PDF file.password(optional) - PDF password (usually your PAN in uppercase).
Output Formats
Call get_pdf_data(format) with one of: "csv" (default), "df", "json", "dicts".
pdf.get_pdf_data("csv") # writes CAS_data_<timestamp>.csv to current directory
df = pdf.get_pdf_data("df") # returns pandas DataFrame
js = pdf.get_pdf_data("json") # returns JSON string
rec = pdf.get_pdf_data("dicts") # returns list of dicts
Output Fields
| Field | Type | Description |
|---|---|---|
fund_name |
str | Mutual fund scheme name |
isin |
str | ISIN code (e.g. INF...) |
scheme_code |
str | AMFI scheme code; empty if lookup fails |
folio_num |
str | Folio number |
date |
str | Transaction date (e.g. 01-Jan-2025) |
txn |
str | Buy or Sell |
amount |
float | Transaction amount (INR) |
units |
float | Units transacted |
nav |
float | NAV at time of transaction |
balance_units |
float | Unit balance after transaction |
Example
import logging
from processCASpdf import ProcessPDF
logging.basicConfig(level=logging.DEBUG) # optional
pdf = ProcessPDF("MyCAS.pdf", password="ABCDE1234F")
df = pdf.get_pdf_data("df")
df[df["fund_name"].str.contains("HDFC", case=False)]
df.to_excel("cas_transactions.xlsx", index=False)
Troubleshooting
| Problem | Likely cause / fix |
|---|---|
PDFPasswordIncorrect |
Wrong or missing password. Try your PAN in uppercase. |
| No transactions extracted | Enable debug logging to inspect raw PDF text. |
scheme_code is empty |
ISIN not found in current AMFI data (new or discontinued scheme). |
| Network error on startup | AMFI data fetch requires outbound HTTPS. |
Development
uv sync --group dev
uv run ruff check .
uv run ruff format .
uv run mypy processCASpdf.py
uv run pre-commit install
Credits
Based on camspdf.py originally written by Suhas Bharadwaj.
Release files for processCASpdf 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| processcaspdf-0.3.1.tar.gz | 115.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| processcaspdf-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 123.2 kB
Release files / processcaspdf-0.3.1.tar.gz
| Download URL | processcaspdf-0.3.1.tar.gz |
|---|---|
| Size | 115.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e7d3ab4e6a4d7d7175b11634345846961f83f5c2bd7d5d508d6d9e8a74e39f3
|
|
BLAKE2b-256 checksum How to use checksums |
c68d41693ceb6f09f908010cc6bf7e66f80aeab20cf24d6283278332fb570bcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / processcaspdf-0.3.1-py3-none-any.whl
| Download URL | processcaspdf-0.3.1-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0824daea2d297891883291f51cf3d7ffe5bb8a2cca0abb45b9a0f5bb7911834b
|
|
BLAKE2b-256 checksum How to use checksums |
f2aeaecad0a1756de4ee94adf366a06f83cc8ad5cce6ecf05d04640220d6055b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|