View unanswered posts | View active topics It is currently 23 Nov 2014 02:24



Post new topic Reply to topic  [ 6 posts ] 
Removing All Spaces from CSV 
Author Message

Joined: 19 Apr 2012 21:53
Posts: 2
Post Removing All Spaces from CSV
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


20 Apr 2012 12:10
Profile

Joined: 01 Jul 2011 08:47
Posts: 114
Post Re: Removing All Spaces from CSV
If only the value have numbers then is this easy.
Code:
@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%


20 Apr 2012 13:55
Profile

Joined: 20 Mar 2012 10:07
Posts: 14
Post Re: Removing All Spaces from CSV
Code:
@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.



20 Apr 2012 14:57
Profile

Joined: 19 Apr 2012 21:53
Posts: 2
Post Re: Removing All Spaces from CSV
Thank you very much that worked great.


20 Apr 2012 14:59
Profile

Joined: 23 Dec 2011 13:59
Posts: 2007
Post 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.


20 Apr 2012 16:13
Profile

Joined: 10 Feb 2012 02:20
Posts: 4412
Post 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.


20 Apr 2012 20:16
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.