The CSV Parser is a PHP script that reads a CSV file, performs data transformation, and writes the results to a new CSV file. This README provides information about how to use the parser, the CSVParser class, and the accompanying PHPUnit test.
The parser.php
script is a command-line utility that accepts the following options:
--file
: The input CSV file path.--unique-combinations
: The output CSV file path.
In order to set column keys for parsed file, modify csvData array. Then map column keys from input to the new columns.
To run the parser, use the following command:
php parser.php --file <input_file> --unique-combinations <output_file>
The CSVParser class encapsulates the functionality of the parser. You can use this class within your PHP code to perform CSV data processing.
The PHPUnit test (CSVParserTest.php) is included to verify the functionality of the CSVParser class. It covers both correct and incorrect input scenarios. To run the tests, ensure PHPUnit is installed and execute the following command:
vendor/bin/phpunit CSVParserTest.php