The case is like this :
I have a csv file with 6 columns without header like below :
5002200,25081,0000002797,6,,2014/06/05
5001111,25081,0000002790,,,2014/06/05
5004901,00081,0000002799,5,,2014/06/05
5004901,00081,0000002796,5,,2014/06/05
The output I want is after sorted and displayed like below:
5001111,25081,0000002790,,,2014/06/05
5002200,25081,0000002797,6,,2014/06/05
5004901,00081,0000002796,5,,2014/06/05
5004901,00081,0000002799,5,,2014/06/05
@echo off
if not exist %1 goto :EOF
setlocal
for /F "tokens=1-6 delims=," %%a in (%1) do set "a[%%b,%%c,%%a,%%d,%%e,%%f]=[]"
break > %1
for /F "tokens=2-7 delims=[,]=" %%a in ('set a[') do echo %%c,%%a,%%b,%%d,%%e,%%f>> %1
endlocal
The problem is the null value would missing. Any idea?
My algorithm is sort the 1st columns and 3nd columns then display as original position. But if there are any empty value(like 4th or 5th columns), it would missed.
First column always contains 7 length.
Only 4th or 5th column would contains empty.