A lightweight, robust Python utility script designed to parse proprietary, text-based data formats into standard Python data structures (lists and dictionaries).
Often, data is exported from legacy systems or specialized hardware in non-standard plaintext formats that standard parsers (like the csv or json modules) cannot read natively. This utility is engineered to parse text files demarcated by specific keywords (COLUMN and END), safely structuring the parsed text into 2-Dimensional lists and Python dictionary objects for downstream analysis.
- 2D List Extraction:
load_data_from_file_into_2D_list()groups text rows under column headers into nested arrays. - Dictionary Extraction:
load_data_from_file_into_dictionary()maps column headers as keys and the subsequent rows as lists of values. - Robust Iteration: Safely handles file line stripping and state-machine-like parsing based on string prefixes.
- Language: Python 3.x (Standard Library only; no external dependencies)
python-data-parser/
├── src/
│ └── parser.py # Core utility functions
├── screenshot.png # Execution output demonstration
└── README.md
You can import and use these utilities directly in your data pipelines.
from src.parser import load_data_from_file_into_2D_list, load_data_from_file_into_dictionary
# Load data into a nested list
data_table = load_data_from_file_into_2D_list('legacy_export.txt')
# Load data into a dictionary for easy key-value access
data_dict = load_data_from_file_into_dictionary('legacy_export.txt')Agha Abdullah
- GitHub: @AGHAABDULLAH
This project is licensed under the MIT License.
