This project is a robust CSV parser. It reads and processes CSV (Comma-Separated Values) files with special attention to formatting edge cases like:
- Quoted fields with embedded commas
- Escaped quotes inside fields
- Inconsistent line endings (
\n
,\r\n
) - Empty fields and empty rows
- Ill-formed CSV data (triggers custom
CSVFormatException
)
- Implements
CSVReader
that reads rows using a customCharacterReader
- Parses fields according to standard CSV rules (RFC 4180-style)
- Throws a custom
CSVFormatException
when CSV rules are violated - Includes comprehensive JUnit test coverage (
CSVReaderTest.java
)
CSVReader.java
– main parser classCharacterReader.java
– reads characters with position trackingCSVFormatException.java
– custom error for invalid CSV formatsCSVReaderTest.java
– JUnit tests that handle normal and edge cases
Make sure you're in the root directory of your project and run:
# Using Maven:
mvn test
# Or in Eclipse:
Right-click → Run As → JUnit Test