A Python system that parses component datasheets and determines compatibility based on operating voltage and temperature ranges.
component_parser.py
- Main parser implementationtest_component_parser.py
- Test suiteTask example files/
- Sample datasheet files for testing the parser- Contains text-extracted datasheets from various electronic components
- Used to verify parser accuracy with real-world examples
- Each file contains voltage and temperature specifications in different formats
- Python 3.x (no additional packages required)
python component_parser.py [-v] # -v for verbose output
When prompted, enter:
- Operating voltage (V)
- Operating temperature (°C)
The program will display all compatible components.
python test_component_parser.py
- Reads component datasheet files (.txt)
- Uses regular expressions to parse:
- Voltage ranges (e.g., "3.15V to 3.45V Operation")
- Temperature ranges (e.g., "-40°C to +85°C")
- For multiple ranges in a file:
- Uses the range if all are identical
- Sets to None if ranges differ
- A component is compatible if both voltage and temperature are within range
- Regular expressions handle various text formats:
- Direct ranges: "3.15V to 3.45V"
- Prefixed ranges: "Supply voltage: 2.7V to 5.5V"
- Suffixed ranges: "3.15V to 3.45V Operation"
- Handles both Latin-1 and UTF-8 encodings
- Validates ranges for reasonable values
- Comprehensive test coverage with unittest
- Voltage specifications contain 'V' or 'v' unit
- Temperature specifications in Celsius (°C, C)
- When multiple ranges exist, they must be identical to be valid
- Voltage and temperature ranges are within reasonable bounds for electronic components