Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Advice needed on best option when splitting data .... 1

Status
Not open for further replies.

rab54

Programmer
Jan 28, 2004
112
GB
Hi gurus -

OK I have data coming in,in this format

"forename","surname","address_1","address_2","address_3" etc

I have been splitting on the commas - no problem

Except there are now addresses that have extar commas in the first field - eg "54,test street","address_2", etc

I have got round this using Text::CSV;

Problem ? We now have records coming in that could have 2,3 or more commas within the address_1 field !

What is my best option ?

Obviously if I could get the data pipe-delimited that would be great .... but don't think I can -

Any ideas would be great .....

cheers in advance

Rab

 
rab

Text::CSV should still look after this for you, as long as its "well-formed" CSV

if not you could try cheating

$test_rec=~ s/","/\|/g;

you'll also have to top and tail the quotes at the start and end of teh string

HTH
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
Cheers Paul -

I have just familiarised myself a bit more with Text::CSV -

you are right I think I am sorted -

re the quotes - I am stripping this out first anyway ....

cheers mate

Rab
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top