(Karvy/Kfintech/CAMS) Consolidated Account Statement (CAS) PDF parser
Project description
CASParser
Parse Consolidated Account Statement (CAS) PDF files generated from CAMS/KFINTECH
Installation
pip install casparser
with faster PyMuPDF parser
pip install casparser[mupdf]
Note: Enabling this dependency could result in licensing changes. Check the License section for more details
Usage
import casparser
data = casparser.read_cas_pdf("/path/to/cas/file.pdf", "password")
# Get data in json format
json_str = casparser.read_cas_pdf("/path/to/cas/file.pdf", "password", output="json")
# Get transactions data in csv string format
csv_str = casparser.read_cas_pdf("/path/to/cas/file.pdf", "password", output="csv")
Data structure
{
"statement_period": {
"from": "YYYY-MMM-DD",
"to": "YYYY-MMM-DD"
},
"file_type": "CAMS/KARVY/UNKNOWN",
"investor_info": {
"email": "string",
"name": "string",
"mobile": "string",
"address": "string"
},
"folios": [
{
"folio": "string",
"amc": "string",
"PAN": "string",
"KYC": "OK/NOT OK",
"PANKYC": "OK/NOT OK",
"schemes": [
{
"scheme": "string",
"advisor": "string",
"rta_code": "string",
"rta": "string",
"open": "number",
"close": "number",
"valuation": {
"date": "date",
"nav": "number",
"value": "number"
},
"transactions": [
{
"date": "YYYY-MM-DD",
"description": "string",
"amount": "number",
"units": "number",
"nav": "number",
"balance": "number",
"type": "string",
"dividend_rate": "number"
}
]
}
]
}
]
}
Notes:
- Transaction
type
can be any value from the followingPURCHASE
PURCHASE_SIP
REDEMPTION
SWITCH_IN
SWITCH_IN_MERGER
SWITCH_OUT
SWITCH_OUT_MERGER
DIVIDEND_PAYOUT
DIVIDEND_REINVESTMENT
TAX
MISC
dividend_rate
is applicable only forDIVIDEND_PAYOUT
andDIVIDEND_REINVESTMENT
transactions.
CLI
casparser also comes with a command-line interface that prints summary of parsed portfolio in a wide variety of formats.
Usage: casparser [-o output_file.json] [-p password] [-s type] [-a] CAS_PDF_FILE
-o, --output FILE Output file path
-s, --summary simple|plain|grid|fancy_grid|html...
Print Summary of transactions parsed.
-p PASSWORD CAS password
-a, --include-all Include schemes with zero valuation in the
summary output
--force-pdfminer Force PDFMiner parser even if MuPDF is
detected
--version Show the version and exit.
-h, --help Show this message and exit.
Note: casparser cli
supports two special output file formats [-o file.json / file.csv]
json
- complete parsed data is exported in json format (including investor info)csv
- transactions with AMC, Folio and Scheme info are exported into csv format.
Demo
License
CASParser is distributed under MIT license by default. However enabling the optional dependency
mupdf
would imply the use of PyMuPDF /
MuPDF and hence the licenses GNU GPL v3 and GNU Affero GPL v3
would apply. Copies of all licenses have been included in this repository. - IANAL
Resources
PS:- select the detailed statement (including transactions) option
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for casparser-0.3.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3681a55f4f612746d56bbb2e234b5f779b46be2bcba6448c0bb3b63b647f4361 |
|
MD5 | 2e9177565f581ad4c76bc9f00134f23d |
|
BLAKE2b-256 | eaf1bb73cfcd0677b906a6353926a148f3ada1efad4a0c86503aa0f11fda5dd2 |