CSV Help (Ignore Comma In Double Quotes)

  • Thread starter Thread starter Crouchie1998
  • Start date Start date
C

Crouchie1998

Guest
Hi,

This isnt exactly what you first have thought by the title and I know how to split a string by a , and is more complicated than that.

I wrote 3 years ago a Windows app that uses the Maxmind Web Service to return information about a chosen IP. I am certainly not interested in links to the Maxmind C# or ASP examples that just return the item as one complete string.

When the data is returned as a CSV, some fields are surrounded by double quotes & usually I just strip those out but with some IPs they return the company name with a comma in the centre of it:

Example: "Some Company Name, LLC"

As the data string is a CSV, that has added one extra field to the returned string. So when I add those split strings to the textboxes to display the information it shows an error because the returned information isnt what is expected to be returned. Because Maxmind arent ever going to change the return to JSON or XML the only thing that can be done if to check if there is a comma between two double quotes and this is the reason for this question.

Normal String:

"US,"UNITED STATES",WA,WASHINGTON,REDMOND,47.6801,122.1206,819,425,AMERICA/LOS_ANGELES,NA,98052,"MICROSOFT HOSTING","MICROSOFT HOSTING",HOTMAIL.COM,"AS8075 MICROSOFT CORPORATION",CORPORATE,HOSTING,937,99,20,60,10,"

Error String (IP: 8.2.120.0):

"US,"UNITED STATES",NJ,"NEW JERSEY",MATAWAN,40.4169,-74.2579,501,732,AMERICA/NEW_YORK,NA,07747,"LEVEL 3 COMMUNICATIONS","CHOOPA, LLC",,"AS20473 CHOOPA, LLC",CORPORATE,HOSTING,937,99,20,60,10,"

See: "CHOOPA, LLC" which causes the error but this example has 2 because it contains "AS20473 CHOOPA, LLC" too.

I need to be able to check for that comma in the above, ignore it in the CSV array but dispay the comma in the textbox as the return field. How do I do it?


Homepage | YouTube Channel | Casual Kiss Dating Site

Please mark as answer if my solution helped you.

Continue reading...
 
Back
Top