Package: casparser
CASParserParse Consolidated Account Statement (CAS) PDF files generated from CAMS/KFINTECHcasparseralso includes a command line tool with the following analysis toolssummary- print portfolio summary(BETA)gains- Print capital gains report (summary and detailed)with option to generate csv files for ITR in schedule 112A formatInstallationpipinstall-Ucasparserwith faster PyMuPDF parserpipinstall-U'casparser[fast]'Note:Enabling this dependency could result in licensing changes. Check theLicensesection for more detailsUsageimportcasparserdata=casparser.read_cas_pdf("/path/to/cas/file.pdf","password")# Get data in json formatjson_str=casparser.read_cas_pdf("/path/to/cas/file.pdf","password",output="json")# Get transactions data in csv string formatcsv_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","cas_type":"DETAILED/SUMMARY","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","isin":"string","amfi":"string","advisor":"string","rta_code":"string","rta":"string","open":"number","close":"number","close_calculated":"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:Transactiontypecan be any value from the followingPURCHASEPURCHASE_SIPREDEMPTIONSWITCH_INSWITCH_IN_MERGERSWITCH_OUTSWITCH_OUT_MERGERDIVIDEND_PAYOUTDIVIDEND_REINVESTMENTSEGREGATIONSTAMP_DUTY_TAXTDS_TAXSTT_TAXMISCdividend_rateis applicable only forDIVIDEND_PAYOUTandDIVIDEND_REINVESTMENTtransactions.CLIcasparser 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|output_file.csv] [-p password] [-s] [-a] CAS_PDF_FILE

  -o, --output FILE               Output file path. Saves the parsed data as json or csv
                                  depending on the file extension. For other extensions, the
                                  summary output is saved. [See note below]

  -s, --summary                   Print Summary of transactions parsed.
  -p PASSWORD                     CAS password
  -a, --include-all               Include schemes with zero valuation in the
                                  summary output
  -g, --gains                     Generate Capital Gains Report (BETA)
  --gains-112a ask|FY2020-21      Generate Capital Gains Report - 112A format for
                                  a given financial year - Use 'ask' for a prompt
                                  from available options (BETA)
  --force-pdfminer                Force PDFMiner parser even if MuPDF is
                                  detected

  --version                       Show the version and exit.
  -h, --help                      Show this message and exit.CLI examples# Print portfolio summary
casparser /path/to/cas.pdf -p password

# Print portfolio and capital gains summary
casparser /path/to/cas.pdf -p password -g

# Save parsed data as a json file
casparser /path/to/cas.pdf -p password -o pdf_parsed.json

# Save parsed data as a csv file
casparser /path/to/cas.pdf -p password -o pdf_parsed.csv

# Save capital gains transactions in csv files (pdf_parsed-gains-summary.csv and
# pdf_parsed-gains-detailed.csv)
casparser /path/to/cas.pdf -p password -g -o pdf_parsed.csvNote:casparser clisupports two special output file formats [-ofile.json/file.csv]json- complete parsed data is exported in json format (including investor info)csv- Summary info is exported in csv format if the input file is a summary statement or if
a summary flag (-s/--summary) is passed as argument to the CLI. Otherwise, full
transaction history is included in the export.
If-gflag is present, two additional files '{basename}-gains-summary.csv',
'{basename}-gains-detailed.csv' are created with the capital-gains data.any other extension - The summary table is saved in the file.DemoISIN & AMFI code supportSince v0.4.3,casparserincludes support for identifying ISIN and AMFI code for the parsed schemes
via the helper modulecasparser-isin. If the parser
fails to assign ISIN or AMFI codes to a scheme, try updating the local ISIN database bycasparser-isin--updateIf it still fails, please raise an issue atcasparser-isinwith the
failing scheme name(s).LicenseCASParser is distributed under MIT license by default. However enabling the optional dependencymupdf/fastwould imply the use ofPyMuPDF/MuPDFand hence the licenses GNU GPL v3 and GNU Affero GPL v3
would apply. Copies of all licenses have been included in this repository. -IANALResourcesCAS from CAMSCAS from Karvy/Kfintech