Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
arun 36985
arrunav 25871
elarital 48734
depaal 43212
sujan 23467


my data is up to 2000+ lines it is in notepad as shown in above for that data how can i replace space with comma?
arun,36985
arrunav,25871
elarital,48734
depaal,43212
sujan,23467
Posted

Try:
C#
string data = File.ReadAllText(path);
data = data.Replace(" ", ",");
File.WriteAllText(path, data);


[edit]Forgot the data! :doh:[/edit]
 
Share this answer
 
v2
Comments
Matt T Heffron 19-Feb-14 13:18pm    
Good, but OP tagged with Perl!
At a unix-like shell (e.g., Cygwin):
perl -pi.bak -e "s/ /,/g;" filename_to_process

In a Command Prompt (DOS shell) assuming the location of perl.exe is on the PATH:
perl.exe -pi.bak -e "s/ /,/g;" filename_to_process
ought to do it...
 
Share this answer
 

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