Pwit
asked on
C# Substring for CSV files
Hi all,
I am trying to parse a CSV file by the commas. I would initially get a index of a comma and everything that and the next comma. It returns what looks like the correct indices, but when I apply it to the code it outputs something entirely different. Is there something special that has to be done when parsing CSV files? Thanks in advance.
Here's a sample of what I am trying to read from the CSV file:
"Internet",278766,"9838551 2","05/01/ 2009","Exc hange, Expert","eRes-Plus - 2022609583","R8",78,7.80," "," ",7.80,""
My goal is to extract just "Exchange, Expert" from the string, but instead I get:
Exchange, Expert","eRes-Plus - 3127554506","R8",105,10.50 ," "
pwit
I am trying to parse a CSV file by the commas. I would initially get a index of a comma and everything that and the next comma. It returns what looks like the correct indices, but when I apply it to the code it outputs something entirely different. Is there something special that has to be done when parsing CSV files? Thanks in advance.
Here's a sample of what I am trying to read from the CSV file:
"Internet",278766,"9838551
My goal is to extract just "Exchange, Expert" from the string, but instead I get:
Exchange, Expert","eRes-Plus - 3127554506","R8",105,10.50
pwit
Here is the code I am trying to use with the index positions already counted out by hand to make sure its right:
text = "Internet",278766,"98385512","05/01/2009","Exchange, Expert","eRes-Plus - 2022609583","R8",78,7.80," "," ",7.80,""
MessageBox.Show(text.Substring(47,62));
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks angelll, that was the trick. For some reason I must have been thinking about the Java substring method or something else.
ASKER
Open in new window