[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Reduce spaces in between 2 words in txt file

Posted on 2007-08-08
6
Medium Priority
?
235 Views
Last Modified: 2010-03-05
Hi,

I have a txt file which has data like this

Sharath     Sharath.reddy@plc.com

I want the data like this
Sharath Sharath.reddy@plc.com

Regards
Sharath
0
Comment
Question by:bsharath
6 Comments
 
LVL 70

Expert Comment

by:KCTS
ID: 19652537
Load it into word  and use filnd/replace to find two spaces and replace with one space - you may need to do the find/replace all several times to get rid of all the double spaces
0
 
LVL 10

Expert Comment

by:LuckyLuke57
ID: 19652598
Or more complete:

Do a first find and replace
- search for the tab-character
- replace with one space

Then as KCTS suggested do as much as you need
- search for two spaces
- replace with one spac

Luke
0
 
LVL 11

Author Comment

by:bsharath
ID: 19652697
But there are a differerent of space
One have 1 space 2,3,4,5,6,7,8,9, so on....
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Expert Comment

by:LuckyLuke57
ID: 19652711
If you start with 1,2,3,4,5,6,7,8,9 spaces
If you do the find and replace the first time, you will have
1, 2,3,4,5,6,7,8 as a result,
One more time find and replace and you have
1, 2,3,4,5,6,7
and do this as much as is necessary
0
 
LVL 10

Expert Comment

by:LuckyLuke57
ID: 19652719
If you have a lot of spaces, you can start with a find and replace from 5 spaces to one which you do a few times, after that you have to do the 2 to 1 only max 4 times.
0
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 total points
ID: 19652848
Try this; just adjust the names of the file to read and the file with the removed spaces:

@echo off
setlocal enabledelayedexpansion
set InputFile=test.txt
set OutputFile=SpacesRemoved.txt
if exist "%OutputFile%" del "%OutputFile%"
for /f "tokens=*" %%a in ('type "%InputFile%"') do (
  set Line=
  for %%l in (%%a) do set Line=!Line! %%l
  >>"%OutputFile%" echo !Line:~1!
)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question