DosTips.com

A Forum all about DOS Batch
It is currently 04 Dec 2016 02:08

All times are UTC-06:00




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
PostPosted: 20 Apr 2012 12:10 
Offline

Joined: 19 Apr 2012 21:53
Posts: 2
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


Top
   
PostPosted: 20 Apr 2012 13:55 
Offline

Joined: 01 Jul 2011 08:47
Posts: 145
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%


Top
   
PostPosted: 20 Apr 2012 14:57 
Offline

Joined: 20 Mar 2012 10:07
Posts: 14
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.

Top
   
PostPosted: 20 Apr 2012 14:59 
Offline

Joined: 19 Apr 2012 21:53
Posts: 2
Thank you very much that worked great.


Top
   
PostPosted: 20 Apr 2012 16:13 
Offline
Expert

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


Top
   
PostPosted: 20 Apr 2012 20:16 
Offline
Expert

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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 6 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
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited