How akshit819/ace_data works
1. Purpose and execution model
- This repository is a Windows-only batch automation tool for processing a list of companies from ace.csv, refreshing a Microsoft Excel template through the AccEquity XL NXT add-in, and then uploading the generated workbooks to tickercharcha.com.
2. Primary entry point
- main.py is the orchestration layer. It likely coordinates the full loop: load configuration, authenticate to the API, iterate over CSV rows, drive Excel automation, save output files, and upload each file.
3. Configuration boundary
- config.py is the central settings loader, reading paths, credentials, retry counts, refresh timing, and cell targets from environment/configuration.
- This keeps runtime parameters outside the code and allows the same workflow to run against different CSVs, templates, and output folders.
4. Input data source
- ace.csv is the operational input feed.
- Each row contains an Accord Code and Company Name; the code becomes the Excel input value, while the company name is used to name the final workbook.
5. Excel automation subsystem
- excel_automation.py is the main boundary to Microsoft Excel via COM automation.
- Its responsibilities are likely:
- open a copy of the template workbook,
- write the Accord Code into the configured cell,
- trigger RefreshAll so the AccEquity add-in fetches data,
- wait for the refresh to settle,
- save the finished workbook to the output folder.
- This subsystem depends on Excel being installed locally and on the AccEquity add-in being available.
6. Template-driven workbook generation
- Template NBFC-Final.xlsx is the workbook seed that gets duplicated and populated per company.
- The architecture is file-based rather than database-based: each company becomes an independent Excel artifact on disk.
7. API upload subsystem
- api_client.py encapsulates authentication and file upload to the external tickercharcha.com API.
- The README indicates it logs in once at startup, extracts a token from common response fields, and re-authenticates automatically if upload requests receive 401/403 responses.
8. Cross-cutting logging
- logger_setup.py centralizes log configuration.
- The system produces both an audit log and an error-only log, plus console output, which is important because the workflow is long-running and continues past per-company failures.
9. End-to-end data flow
- The flow is: CSV row → Excel template copy → COM write + refresh → saved workbook → API upload → logs.
- Each company is processed independently, so failure in one row does not stop the batch.
10. Error-handling and retry boundaries
- The architecture is designed for resilience at two fragile points:
- Excel automation/refresh can retry when Excel or the add-in is slow or temporarily unavailable.
- Uploads can retry and re-authenticate when the API token expires.
- The main loop appears to isolate failures per company rather than failing the whole batch.
11. Runtime and infrastructure assumptions
- The project depends on a local Windows desktop environment with Python 3.10+, Microsoft Excel, and the COM stack provided by pywin32 or equivalent dependencies.
- It is not a cloud service or server application; the “infrastructure” is the operator’s workstation plus external API access.
12. Repository shape
- The repo is intentionally small and modular: orchestration in main.py, configuration in config.py, Excel integration in excel_automation.py, API integration in api_client.py, and logging in logger_setup.py.
- That separation makes the architecture easy to diagram as three main zones: input/config, Excel generation, and API delivery, with logging spanning all of them.
Main entry points: main.py Main loop · excel_automation.py Excel automation · logger_setup.py Logging · api_client.py API client
Components 15
Input & config
Operational inputs and runtime settings.
- Settings · Loads paths, credentials, retry values, and cell targets.
config.py - ACE list · Per-company source rows with Accord Code and Company Name.
ace.csv - Workbook seed · Base workbook copied for each company output.
Template NBFC-Final.xlsx
Excel generation
Windows COM automation that produces the workbooks.
- Excel automation · Windows Excel boundary for opening, writing, refreshing, and saving workbooks.
excel_automation.py - Open copy · Creates a per-company workbook from the template.
- Write code · Places the Accord Code into the configured worksheet cell.
- Refresh data · Triggers Excel refresh so the AccEquity add-in fetches updated values.
- Save workbook · Writes the finished workbook to the output folder.
API delivery
Upload and session handling for the external service.
- API client · Handles login, token reuse, re-authentication, and file upload.
api_client.py - Login · Authenticates to the tickercharcha.com API and stores a token.
- Upload file · Posts generated workbooks to the external service.
- Retry auth · Re-authenticates when uploads return unauthorized responses.
Operations
Cross-cutting orchestration and logging.
Connections 18
- Main loop → Settings: load settings · Reads runtime parameters and file locations.
- Main loop → ACE list: iterate rows · Processes each company independently from the input list.
- Main loop → Excel automation: generate workbook · Delegates per-company workbook creation and refresh.
- Main loop → API client: upload artifact · Sends each completed workbook to the external API.
- Main loop → Logging: write logs · Emits progress, audit, and error messages.
- Excel automation → Workbook seed: seed from · Uses the template workbook as the starting artifact.
- Excel automation → Open copy: creates · Opens a company-specific copy of the template.
- Open copy → Write code: passes workbook · Hands the workbook to the cell-writing step.
- Write code → Refresh data: triggers · Starts refresh after the input value is written.
- Refresh data → Save workbook: produces · Saves the refreshed workbook to disk.
- Excel automation → Windows desktop: depends on · Requires local Windows Excel and COM automation.
- API client → Login: authenticate · Obtains an initial access token.
- API client → Upload file: send file · Uploads generated workbook files.
- Upload file → Retry auth: on 401/403 · Re-authenticates when the token expires or is rejected.
- Retry auth → Login: renew token · Fetches a fresh token before retrying upload.
- Logging → Main loop: observe · Captures long-running batch progress and failures.
- Logging → Excel automation: observe · Records Excel automation warnings and errors.
- Logging → API client: observe · Records API authentication and upload events.