This project provides a simple tool for validating ISO container numbers, including SOC (Shipper Owned Containers).
It ensures that container numbers conform to the required format and validates check digits according to the ISO 6346 standard.
This implementation uses the Polars library for data handling and is intended for developers familiar with Python and Rust's polars.
- Validate container numbers: Ensure container numbers follow the correct pattern (4 letters, 6 digits, 1 check digit).
- SOC (Shipper Owned Container) validation: Validate SOC numbers using a predefined list of valid SOCs from a TOML file.
- Check digit validation: Verifies the check digit using ISO 6346 standards.
- Support for Parquet files: Reads container numbers from Parquet files using Polars.
- Python 3.10+
- Poetry for managing dependencies
- Polars for efficient data handling
- TOML for configuration file handling
-
Clone the repository:
git clone https://github.com/Attica-oss/container_iso_check.git cd container_iso_check -
Install dependencies using Poetry:
poetry install
This will create a virtual environment and install all necessary dependencies.
The project uses the following Python libraries:
- Polars: Efficient data frame library for Rust and Python (
polars) - TOML: Used for reading SOC numbers from a TOML file (
toml) - re: Regular expressions for container number format validation
You can find the list of dependencies in pyproject.toml managed by Poetry.
Run the application using Python:
poetry run python /path/to/main.py-
Manual input: You can input container numbers directly when prompted.
-
Reading from a file: By default, the tool looks for a Parquet file for container numbers, and it reads unique entries from the file.
-
SOC Validation: SOC numbers can be validated against a predefined list of SOCs in the
app/SOC.tomlfile.
[soc]
containers = ["XXXX1234567", "XXXX2345678"]To use the ContainerValidator class:
from app.app import ContainerValidator
validator = ContainerValidator()
container_numbers = validator.read_input() # Manually input or read from Parquet
validation_results = validator.validate_container_numbers(container_numbers)
print(validation_results)This will output validation results for each container number.
- Standard format: 4 letters, 6 digits, followed by a check digit (e.g.,
ABCD1234567). - SOC number: Starts with
XXXXfollowed by digits, validated against the TOML file.
To run tests, make sure you have installed all dependencies and use:
poetry run pytestIf you'd like to contribute to this project, please follow the steps below:
- Fork the repository.
- Create a new branch.
- Make your changes and commit them.
- Push the changes to your fork.
- Create a pull request.
This project is licensed under the MIT License.
- Ensure that the
app/SOC.tomlfile contains valid SOC numbers for correct SOC validation. - Container numbers must follow the ISO 6346 standard for validation to pass.
