in reply to Re: Parsing CSV
in thread Parsing CSV
Dave
Thanks for the response. I am a bit new here and did look at Text::CSV, but couldn't figure out how to solve the entire issue. I was hoping to also remove the comma in the names in the same pass.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Parsing CSV
by davido (Cardinal) on Apr 04, 2014 at 17:12 UTC | |
Text::CSV won't do it directly, but if you're ok with just blindly removing commas, you can do this:
...which produces...
That seems like it's almost there. But if you need to reverse the order of "words" within the fields that have embedded commas, you could do this:
...which puts "lname, fname mi" into "fname mi lname" order, providing the following results:
FWIW, I am happy to deal with questions where a commonly used CPAN solution is falling short of what you need, but the original question made no mention of what solutions had been explored, or how they failed to meet the need. You tend to get warmer and far more useful responses if you provide us with details on what you tried, how it failed to fill the requirement, a small self-contained code example, sample input (as you did), and sample output. Often, in composing an effective question, the research that goes into its composition leads you to the answer without even asking. But in those cases where the answer is still elusive, you'll be able to demonstrate exactly what small part of the bigger picture is holding you up so that our answers hit the mark on the first try, rather than after a round or two of follow-ups (as has been the case here). I like giving good answers. But sometimes I simply can't devote the time because it's obvious that it's going to take several rounds of asking for additional information before we get to the meat of the problem. That's an unfortunate situation for the person asking, because his question doesn't get the quality of answers he needs, when it could have gotten a quick and accurate answer had it only provided more context. Anyway, welcome to the Monastery, and I hope you find it both helpful and encouraging to your efforts to learn Perl. Dave | [reply] [d/l] [select] |