processCASpdf 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- processcaspdf-0.3.1/.github/workflows/publish.yml +28 -0
- processcaspdf-0.3.1/.gitignore +25 -0
- processcaspdf-0.3.1/.pre-commit-config.yaml +15 -0
- processcaspdf-0.3.1/LICENSE +21 -0
- processcaspdf-0.3.1/PKG-INFO +118 -0
- processcaspdf-0.3.1/README.md +93 -0
- processcaspdf-0.3.1/processCASpdf.py +473 -0
- processcaspdf-0.3.1/pyproject.toml +81 -0
- processcaspdf-0.3.1/uv.lock +1688 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
workflow_dispatch: {}
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
publish:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
environment: pypi
|
|
16
|
+
permissions:
|
|
17
|
+
id-token: write # required for PyPI trusted publishing (OIDC)
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v5
|
|
23
|
+
|
|
24
|
+
- name: Build
|
|
25
|
+
run: uv build
|
|
26
|
+
|
|
27
|
+
- name: Publish to PyPI
|
|
28
|
+
run: uv publish
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Virtual environment
|
|
2
|
+
.venv/
|
|
3
|
+
|
|
4
|
+
# Python
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.pyc
|
|
7
|
+
*.pyo
|
|
8
|
+
|
|
9
|
+
# IDE
|
|
10
|
+
.idea/
|
|
11
|
+
.vscode/
|
|
12
|
+
*.swp
|
|
13
|
+
.claude/
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
.mypy_cache/
|
|
16
|
+
*.txt
|
|
17
|
+
test/
|
|
18
|
+
|
|
19
|
+
# local memory
|
|
20
|
+
.memcord
|
|
21
|
+
.mcp.json
|
|
22
|
+
|
|
23
|
+
# OS
|
|
24
|
+
.DS_Store
|
|
25
|
+
Thumbs.db
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
3
|
+
rev: v0.9.7
|
|
4
|
+
hooks:
|
|
5
|
+
- id: ruff
|
|
6
|
+
args: [--fix]
|
|
7
|
+
- id: ruff-format
|
|
8
|
+
|
|
9
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
10
|
+
rev: v1.14.1
|
|
11
|
+
hooks:
|
|
12
|
+
- id: mypy
|
|
13
|
+
additional_dependencies:
|
|
14
|
+
- pandas-stubs
|
|
15
|
+
- types-requests
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Neeraj Tikku
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: processCASpdf
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Extract data from CAMS Mutual Fund PDF statements
|
|
5
|
+
Project-URL: Homepage, https://github.com/ukkit/processCASpdf
|
|
6
|
+
Project-URL: Repository, https://github.com/ukkit/processCASpdf
|
|
7
|
+
Project-URL: Issues, https://github.com/ukkit/processCASpdf/issues
|
|
8
|
+
Author-email: Neeraj Tikku <neeraj.tikku@gmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Requires-Dist: pandas>=1.3.0
|
|
22
|
+
Requires-Dist: pdfplumber>=0.7.0
|
|
23
|
+
Requires-Dist: requests>=2.25.0
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# Mutual Fund CAS PDF Statement Parser
|
|
27
|
+
|
|
28
|
+
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.
|
|
29
|
+
|
|
30
|
+
## Requirements
|
|
31
|
+
|
|
32
|
+
- Python >= 3.9
|
|
33
|
+
- [uv](https://github.com/astral-sh/uv) package manager
|
|
34
|
+
- Internet connection (fetches AMFI scheme data on each run)
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git clone https://github.com/ukkit/processCASpdf.git
|
|
40
|
+
cd processCASpdf
|
|
41
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
42
|
+
uv sync
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from processCASpdf import ProcessPDF
|
|
49
|
+
|
|
50
|
+
pdf = ProcessPDF("CAS_statement.pdf", password="your_pdf_password")
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- `filename` (required) - Path to the CAS PDF file.
|
|
54
|
+
- `password` (optional) - PDF password (usually your PAN in uppercase).
|
|
55
|
+
|
|
56
|
+
### Output Formats
|
|
57
|
+
|
|
58
|
+
Call `get_pdf_data(format)` with one of: `"csv"` (default), `"df"`, `"json"`, `"dicts"`.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
pdf.get_pdf_data("csv") # writes CAS_data_<timestamp>.csv to current directory
|
|
62
|
+
df = pdf.get_pdf_data("df") # returns pandas DataFrame
|
|
63
|
+
js = pdf.get_pdf_data("json") # returns JSON string
|
|
64
|
+
rec = pdf.get_pdf_data("dicts") # returns list of dicts
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Output Fields
|
|
68
|
+
|
|
69
|
+
| Field | Type | Description |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| `fund_name` | str | Mutual fund scheme name |
|
|
72
|
+
| `isin` | str | ISIN code (e.g. `INF...`) |
|
|
73
|
+
| `scheme_code` | str | AMFI scheme code; empty if lookup fails |
|
|
74
|
+
| `folio_num` | str | Folio number |
|
|
75
|
+
| `date` | str | Transaction date (e.g. `01-Jan-2025`) |
|
|
76
|
+
| `txn` | str | `Buy` or `Sell` |
|
|
77
|
+
| `amount` | float | Transaction amount (INR) |
|
|
78
|
+
| `units` | float | Units transacted |
|
|
79
|
+
| `nav` | float | NAV at time of transaction |
|
|
80
|
+
| `balance_units` | float | Unit balance after transaction |
|
|
81
|
+
|
|
82
|
+
### Example
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import logging
|
|
86
|
+
from processCASpdf import ProcessPDF
|
|
87
|
+
|
|
88
|
+
logging.basicConfig(level=logging.DEBUG) # optional
|
|
89
|
+
|
|
90
|
+
pdf = ProcessPDF("MyCAS.pdf", password="ABCDE1234F")
|
|
91
|
+
df = pdf.get_pdf_data("df")
|
|
92
|
+
|
|
93
|
+
df[df["fund_name"].str.contains("HDFC", case=False)]
|
|
94
|
+
df.to_excel("cas_transactions.xlsx", index=False)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Troubleshooting
|
|
98
|
+
|
|
99
|
+
| Problem | Likely cause / fix |
|
|
100
|
+
|---|---|
|
|
101
|
+
| `PDFPasswordIncorrect` | Wrong or missing password. Try your PAN in uppercase. |
|
|
102
|
+
| No transactions extracted | Enable debug logging to inspect raw PDF text. |
|
|
103
|
+
| `scheme_code` is empty | ISIN not found in current AMFI data (new or discontinued scheme). |
|
|
104
|
+
| Network error on startup | AMFI data fetch requires outbound HTTPS. |
|
|
105
|
+
|
|
106
|
+
## Development
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
uv sync --group dev
|
|
110
|
+
uv run ruff check .
|
|
111
|
+
uv run ruff format .
|
|
112
|
+
uv run mypy processCASpdf.py
|
|
113
|
+
uv run pre-commit install
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Credits
|
|
117
|
+
|
|
118
|
+
Based on [`camspdf.py`](https://github.com/srbharadwaj/CAMSPdfExtractor) originally written by Suhas Bharadwaj.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Mutual Fund CAS PDF Statement Parser
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Python >= 3.9
|
|
8
|
+
- [uv](https://github.com/astral-sh/uv) package manager
|
|
9
|
+
- Internet connection (fetches AMFI scheme data on each run)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
git clone https://github.com/ukkit/processCASpdf.git
|
|
15
|
+
cd processCASpdf
|
|
16
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
17
|
+
uv sync
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from processCASpdf import ProcessPDF
|
|
24
|
+
|
|
25
|
+
pdf = ProcessPDF("CAS_statement.pdf", password="your_pdf_password")
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- `filename` (required) - Path to the CAS PDF file.
|
|
29
|
+
- `password` (optional) - PDF password (usually your PAN in uppercase).
|
|
30
|
+
|
|
31
|
+
### Output Formats
|
|
32
|
+
|
|
33
|
+
Call `get_pdf_data(format)` with one of: `"csv"` (default), `"df"`, `"json"`, `"dicts"`.
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
pdf.get_pdf_data("csv") # writes CAS_data_<timestamp>.csv to current directory
|
|
37
|
+
df = pdf.get_pdf_data("df") # returns pandas DataFrame
|
|
38
|
+
js = pdf.get_pdf_data("json") # returns JSON string
|
|
39
|
+
rec = pdf.get_pdf_data("dicts") # returns list of dicts
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Output Fields
|
|
43
|
+
|
|
44
|
+
| Field | Type | Description |
|
|
45
|
+
|---|---|---|
|
|
46
|
+
| `fund_name` | str | Mutual fund scheme name |
|
|
47
|
+
| `isin` | str | ISIN code (e.g. `INF...`) |
|
|
48
|
+
| `scheme_code` | str | AMFI scheme code; empty if lookup fails |
|
|
49
|
+
| `folio_num` | str | Folio number |
|
|
50
|
+
| `date` | str | Transaction date (e.g. `01-Jan-2025`) |
|
|
51
|
+
| `txn` | str | `Buy` or `Sell` |
|
|
52
|
+
| `amount` | float | Transaction amount (INR) |
|
|
53
|
+
| `units` | float | Units transacted |
|
|
54
|
+
| `nav` | float | NAV at time of transaction |
|
|
55
|
+
| `balance_units` | float | Unit balance after transaction |
|
|
56
|
+
|
|
57
|
+
### Example
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
import logging
|
|
61
|
+
from processCASpdf import ProcessPDF
|
|
62
|
+
|
|
63
|
+
logging.basicConfig(level=logging.DEBUG) # optional
|
|
64
|
+
|
|
65
|
+
pdf = ProcessPDF("MyCAS.pdf", password="ABCDE1234F")
|
|
66
|
+
df = pdf.get_pdf_data("df")
|
|
67
|
+
|
|
68
|
+
df[df["fund_name"].str.contains("HDFC", case=False)]
|
|
69
|
+
df.to_excel("cas_transactions.xlsx", index=False)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Troubleshooting
|
|
73
|
+
|
|
74
|
+
| Problem | Likely cause / fix |
|
|
75
|
+
|---|---|
|
|
76
|
+
| `PDFPasswordIncorrect` | Wrong or missing password. Try your PAN in uppercase. |
|
|
77
|
+
| No transactions extracted | Enable debug logging to inspect raw PDF text. |
|
|
78
|
+
| `scheme_code` is empty | ISIN not found in current AMFI data (new or discontinued scheme). |
|
|
79
|
+
| Network error on startup | AMFI data fetch requires outbound HTTPS. |
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
uv sync --group dev
|
|
85
|
+
uv run ruff check .
|
|
86
|
+
uv run ruff format .
|
|
87
|
+
uv run mypy processCASpdf.py
|
|
88
|
+
uv run pre-commit install
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Credits
|
|
92
|
+
|
|
93
|
+
Based on [`camspdf.py`](https://github.com/srbharadwaj/CAMSPdfExtractor) originally written by Suhas Bharadwaj.
|