Samir wrote:Thank you Squashman. Did you see the tokens=3* for my 3 column solution? This works, but it is correct?
You said it worked in your previous post so your hypotheses must be correct.
Moderator: DosItHelp
Samir wrote:Thank you Squashman. Did you see the tokens=3* for my 3 column solution? This works, but it is correct?
True, but I think 2* might have worked instead of the 1-2* you recommended for two columns (I never implemented 2 columns since I had a duplicate in column 2 and had to use a 3rd column).Squashman wrote:Samir wrote:Thank you Squashman. Did you see the tokens=3* for my 3 column solution? This works, but it is correct?
You said it worked in your previous post so your hypotheses must be correct.
Samir wrote:Code: Select all
@echo off
(
for /f "tokens=1-3* delims=," %%A in (test.csv) do @echo(%%C,%%B,%%A,%%B,%%C,%%D
)|sort|for /f "tokens=1* delims=," %%A in ('findstr "^"') do @echo(%%C
Okay, I understand this better.Squashman wrote:Samir wrote:Code: Select all
@echo off
(
for /f "tokens=1-3* delims=," %%A in (test.csv) do @echo(%%C,%%B,%%A,%%B,%%C,%%D
)|sort|for /f "tokens=1* delims=," %%A in ('findstr "^"') do @echo(%%C
This was your original code where you were trying to sort by two columns. Because you are echoing %%C which in theory should have nothing in it because the tokens are set to 1*. That means %%A gets the value of %%C from the first echo and %%B gets everything else from the first echo. %%C would get nothing because it is the third token and you didn't assign anything to it. So technically your tokens should have been set to 1-2*.
Depending on how you set your tokens will factor into which tokens you are going to echo.