You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Reader has a addFormatter method where you can register a callback to format the record before it is accessible by any other mechanism. Nothing prevents you do to something like this.
________________________________
From: ignace nyamagana butera ***@***.***>
Sent: Wednesday, January 31, 2024 5:32:01 PM
To: thephpleague/csv ***@***.***>
Cc: Petr Kateřiňák ***@***.***>; Author ***@***.***>
Subject: Re: [thephpleague/csv] Feature request: Trim parsed csv strings (Issue #517)
The Reader has a addFormatter method where you can register a callback to format the record before it is accessible by any other mechanism. Nothing prevents you do to something like this.
$reader = Reader::createFromPath($path);
$reader->addFormatter(fn (array $record): array => array_map(trim(...), $record));
foreach (reader as $record) {
//
}
Hope it will help you.
—
Reply to this email directly, view it on GitHub<#517 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZTLIZIG6B6VW6ILY4RIXNDYRJWYDAVCNFSM6AAAAABCSWMZV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJZGQ3DQOBZGA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
[Inove]
Petr Kateřiňák
***@***.***
www.inove.cz<https://www.inove.cz>
Facebook <https://www.facebook.com/inovecz> LinkedIn <https://www.linkedin.com/company/inove-sro/>
Feature Request
Proposal
It would be nice to have possibility to automatically trim() parsed strings. Something like
So I dont need to use this code each time I'm parsing CSVs:
The text was updated successfully, but these errors were encountered: