I'm trying to manipulate a simple data series set (input data) as listed below to get an output csv file as shown below. I have been trying really hard to work out where the bugs are and how to code this script, but could not work it out.
The main thing I'm trying to do is find a really fast code that can remove the dot from the currency FX prices only and not remove the dot from the date. The solution that was provided in this thread will take 56 hours to manipulate 6.6 million rows of data in just 1 file, which is a very long time to wait, as I have around 50 files to do, so this would take around 117 days to do this job using the code posted here. The code programmed by "Magoo" was amazingly fast, around 10 times faster than other codes posted. I did not realize that the way a batch script is coded can make a very large difference to the time it takes to complete my data manipulation job.
Would Magoo or someone else on this forum be able to modify Magoo's code (which is posted below) so that the code can remove the dot in the Currency prices, but not remove the dot in the date, please also see input data and output data listed below.
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
rem The following settings for the source directory, destination directory, target directory,
rem batch directory, filenames, output filename and temporary filename [if shown] are names
rem that I use for testing and deliberately include names which include spaces to make sure
rem that the process works using such names. These will need to be changed to suit your situation.
SET "sourcedir=u:\your files"
SET "destdir=u:\your results"
SET "filename1=%sourcedir%\q65529783.csv"
SET "outfile=%destdir%\outfile.csv"
(
FOR /f "usebackqtokens=1-7delims=," %%a IN ("%filename1%") DO (
FOR /f "tokens=1-4delims=." %%s IN ("%%d.%%e") DO SET /a value=(%%s*100000^)+1%%t-(%%u*100000^)-1%%v&SET /a value=10*value+1
ECHO %%a,%%b,%%c,%%d,%%e,%%f,!value!
)
)>"%outfile%"
GOTO :EOF
INPUT DATA:
2003.05.04,21:00,118.940,118.952,118.940,118.952,13
2003.05.04,21:01,118.961,118.967,118.958,118.967,13
2003.05.04,21:02,118.972,118.972,118.955,118.955,18
2003.05.04,21:03,118.953,118.961,118.949,118.949,21
2003.05.04,21:04,118.953,118.953,118.946,118.946,8
OUTPUT DATA SHOULD LOOK LIKE THIS:
2003.05.04,21:00,118940,118952,118940,118952,13
2003.05.04,21:01,118961,118967,118958,118967,13
2003.05.04,21:02,118972,118972,118955,118955,18
2003.05.04,21:03,118953,118961,118949,118949,21
2003.05.04,21:04,118953,118953,118946,118946,8