pbassnote has asked for the wisdom of the Perl Monks concerning the following question:
I am working with a csv file of several fields of data, but I only need help with re-formatting a name field. The name field is a variable-length, slash-separated (/) data that can be in any of these various formats:
George Washington/GOV/VA/US John Adams/GOV/MA/US John Q Adams/GOV/MA/US John Q Adams Jr/GOV/MA/US John Q Adams JR/NonEmployee/GOV/MA/US Thomas Jefferson/GOV/VA/US
As you can see, most of these lines have a name followed by three slash-separated bits of data, but some will have more. All I need from this is the name part of the data. Everything from the first "/", including the slash character isn't needed.
With the name, I need to re-format into two fields for last name, and first name, to put into a csv file, so that the above data needs to come out as:
Washington, George Adams, John Adams, John Q Adams Jr, John Q etc.
I've considered using some kind of split() statement to separate the name field by the slashes, but I don't know how to do that? Also, how to reverse the names to display last name before first name?
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to re-format a name field
by toolic (Bishop) on Sep 30, 2014 at 18:50 UTC | |
|
Re: How to re-format a name field
by davido (Cardinal) on Sep 30, 2014 at 18:30 UTC | |
|
Re: How to re-format a name field
by MidLifeXis (Monsignor) on Sep 30, 2014 at 19:59 UTC |