I need a little help with a csv file. I need to remove all the spaces in the file. I would like to do this in a batch file, so I can use windows task scheduler to automate the removal of the spaces.
Example
41712, 1200, 113.6539, 63.724998, 12.974346
41712, 1215, 113.724701, 63.612499, 13.04028
41712, 1230, 113.770203, 63.724998, 13.07691
41712, 1245, 113.805603, 63.724998, 13.11354
41712, 1300, 113.837601, 63.612499, 13.142844
Removing All Spaces from CSV
Moderator: DosItHelp
Re: Removing All Spaces from CSV
If only the value have numbers then is this easy.
Code: Select all
@echo off
set oldfile=oldfile.csv
set newfile=newfile.csv
for /f "tokens=1-5" %%a in (%oldfile%) do echo %%a%%b%%c%%d%%e >>%newfile%
-
- Posts: 14
- Joined: 20 Mar 2012 10:07
Re: Removing All Spaces from CSV
Code: Select all
@echo off & setlocal enabledelayedexpansion
set in=file.csv
set out=file2.csv
for /f "tokens=*" %%i in ('type %in%') do (
set line=%%i
>>%out% echo !line: =!
)
Last edited by tonysathre on 20 Apr 2012 15:02, edited 2 times in total.
-
- Posts: 2
- Joined: 19 Apr 2012 21:53
Re: Removing All Spaces from CSV
Thank you very much that worked great.
Re: Removing All Spaces from CSV
One of my favorite uses of the TR command from my days of being a Linux admin. They have a port of it for windows.
Re: Removing All Spaces from CSV
Also, a change utility will do it simply. Bruce Guthrie wrote a swag of 16 bit freeware utilities including change.exe - they only work with short filenames but are still effective.
And SED is a good contender too.
The batch script is good too though in this case.
And SED is a good contender too.
The batch script is good too though in this case.