Skip to content

Csv fix#56

Merged
jefryelb merged 2 commits into
mainfrom
csv_fix
Jun 10, 2026
Merged

Csv fix#56
jefryelb merged 2 commits into
mainfrom
csv_fix

Conversation

@jefryelb

@jefryelb jefryelb commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Fix CSV import failing for exports with quoted rows

The CSV export wraps each data row in outer quotes (e.g. "1234,Jan,,Jansen,M,...") which caused csv.DictReader to treat the entire line as a single field. This resulted in all columns except the first being None, crashing with 'NoneType' object has no attribute 'strip'.

Added a pre-processing step in parse_csv that strips outer quotes from data rows and unescapes doubled quotes before passing the content to DictReader.

@jefryelb jefryelb requested a review from tiptenbrink June 9, 2026 19:57
@jefryelb

jefryelb commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Ik zie dat de checks weer gemaild zijn, maar ik ben verder gegaan vanaf de development op Mac branch, dus ik zie niet zo goed hoe ik dat niet goed gedaan kon hebben @tiptenbrink
Laat vooral weten wat de acties vanuit mij zouden moeten zijn om dit toch te fixen

@tiptenbrink

Copy link
Copy Markdown
Collaborator

@jefryelb Nee je hebt het goed gedaan, hij klaagt gewoon over de nieuwe code.

Als je tegen je agent zegt: "Fix het totdat uv run ruff" geen errors meer geeft" dan moet ie op een gegeven moment slagen!

De error is:


PLW2901 `for` loop variable `line` overwritten by assignment target
   --> src/apiserver/sync.py:203:13
    |
201 |         cleaned_lines = [lines[0].strip()]
202 |         for line in lines[1:]:
203 |             line = line.strip()
    |             ^^^^
204 |             if line.startswith('"') and line.endswith('"'):
205 |                 line = line[1:-1].replace('""', '"')
    |

PLW2901 `for` loop variable `line` overwritten by assignment target
   --> src/apiserver/sync.py:205:17
    |
203 |             line = line.strip()
204 |             if line.startswith('"') and line.endswith('"'):
205 |                 line = line[1:-1].replace('""', '"')
    |                 ^^^^
206 |             cleaned_lines.append(line)
207 |         content = "\n".join(cleaned_lines)
    |

Found 2 errors.

@jefryelb

Copy link
Copy Markdown
Contributor Author

@tiptenbrink Thanks hahah, was alweer vergeten dat hier ruff checks op zaten
Zeer terechte error ook wel! Ik heb een nieuwe csv van Lou gekregen en die werkt ook, dus qua functionaliteit zit deze pr goed (vanuit mijn testing)

@tiptenbrink tiptenbrink left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase nog even op main zodat je de aanpassingen niet weer undo'd.

git fetch
en daarna
git rebase origin/main
en als je conflicts krijgt, gewoon resolven zodat het weer was zoals op main voor die files

@tiptenbrink

Copy link
Copy Markdown
Collaborator

Maar daarna gewoon lekker zelf mergen!

jefryelb added 2 commits June 10, 2026 22:53
- Strip BOM and whitespace from CSV content consistently
- Unwrap outer quotes from data rows to allow proper field parsing
- Preserve inner quotes by converting escaped quotes back to single quotes
- Fixes parsing errors when CSV exports wrap each row in outer quotes
@jefryelb

Copy link
Copy Markdown
Contributor Author

@tiptenbrink thanks voor je hulp man!

@jefryelb jefryelb merged commit bdde23b into main Jun 10, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants