lancerxe
asked on
replace commas in the double quotes so that I am able to use String.Split
I have a csv file that I'm trying to read.
It was working fine until they started adding the 2nd column
As you can imagine because of that , in the 2nd column the split
shifts eveyrthng.
Here's s a sample:
Account Customer name Amount TC Post Date Transaction Description
0000001 Rachel M, Friends 0.68 xx Aug-10 DISCOVER NETWORK STARS
0000002 Donald M. Bner JR -28.8 xy Aug-10 D CLARKE - CHK ORDERS
I need to remove the , from Rachel M, Friends before I do the split.
thanks
It was working fine until they started adding the 2nd column
As you can imagine because of that , in the 2nd column the split
shifts eveyrthng.
Here's s a sample:
Account Customer name Amount TC Post Date Transaction Description
0000001 Rachel M, Friends 0.68 xx Aug-10 DISCOVER NETWORK STARS
0000002 Donald M. Bner JR -28.8 xy Aug-10 D CLARKE - CHK ORDERS
I need to remove the , from Rachel M, Friends before I do the split.
thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want the commas removed, you can add a line such as
s = Regex.Replace(s, ",", "");
to remove all commas from string s.
s = Regex.Replace(s, ",", "");
to remove all commas from string s.
To be more precise, if you want the commas removed from within columns, replace line 23 with:
currentField = Regex.Replace(currentField _loopVaria ble, ",", "");
currentField = Regex.Replace(currentField
@shadow77
My example is in C# ;)
My example is in C# ;)
@kaufmed
Sorry if I was unclear. I didn't mean to suggest any problem with your example. I found a longer one with more detail on an MS site. The MS example was in VB, so I translated it and added some comments.
Your pointing out the TextFieldParser class is the key contribution here. That class is perfect for problems such as this.
;)
Sorry if I was unclear. I didn't mean to suggest any problem with your example. I found a longer one with more detail on an MS site. The MS example was in VB, so I translated it and added some comments.
Your pointing out the TextFieldParser class is the key contribution here. That class is perfect for problems such as this.
;)
I misread your post, sorry :)
ASKER
I asked the client to send an excel spreadsheet instead.
thanks
lancerx
thanks
lancerx
Fox