# CSV parser silently trims leading/trailing whitespace from quoted fields

- **ID:** `data/csv-whitespace-trimming`
- **Domain:** data
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Many CSV parsers (e.g., pandas read_csv, Excel) trim whitespace from quoted fields by default, but some do not, causing data inconsistency between systems.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| pandas 2.0.0 | active | — | — |
| Python csv module 3.11 | active | — | — |
| Apache Spark 3.4.0 | active | — | — |

## Workarounds

1. **Use pandas with skipinitialspace=False: df = pd.read_csv('file.csv', skipinitialspace=False)** (95% success)
   ```
   Use pandas with skipinitialspace=False: df = pd.read_csv('file.csv', skipinitialspace=False)
   ```
2. **Wrap fields in quotes and use a parser that preserves whitespace: csv.reader(csvfile, skipinitialspace=False)** (90% success)
   ```
   Wrap fields in quotes and use a parser that preserves whitespace: csv.reader(csvfile, skipinitialspace=False)
   ```

## Dead Ends

- **Setting quoting=csv.QUOTE_NONE in Python's csv module** — This disables all quoting and may break fields containing commas. (85% fail)
- **Adding a post-processing step to re-add whitespace based on original file** — Does not affect how the CSV is parsed, only how data is validated. (70% fail)
