Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to replace a comma with a space when it finds at every character
because my csv file contains comma in the data also
Posted
Comments
Sergey Alexandrovich Kryukov 20-May-11 21:17pm    
Don't you understand that you don't formulate the problem?
You need to provide the information: how to tell the difference between comma as the delimiter between the data items and inside data. It may even happen that the data is invalid, so the problem may be non-solvable. How do we know that?
--SA

There is no easy solution. Although you could use a simple string.replace it will find the commas in the data fields also not just the field separators.
You may want to look at this tool, http://www.filehelpers.com/[^]
 
Share this answer
 
Comments
Christoph Keller 20-May-11 8:26am    
Thank you for the link, nice to know that such a library exists!
my 5+!

Have a nice day and happy coding,
Stops
Read the file into a string and then content.Replace(",", " ") and save the result back to the file.
 
Share this answer
 
Comments
[no name] 20-May-11 8:46am    
That won't work. The OP has even said there are commas in the data. Think about it. If you have a scenario where there are three fields, id, name(first and last), date. and the name field is in the format last name, first name. How will string.Replace be able to determine the difference between the comma separating the ID and name field from the last name, first name data?
R. Giskard Reventlov 20-May-11 8:57am    
Oops! You're right: my fault for not reading the question properly: good spot.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900