This should do, what you want.
It works with a comma delimited csv-file, but you can change that to your needs (delims=
):
@echo off
for /F "tokens=1* delims=," %%i in (file.csv) do (
echo %%i,%%j >>%%i.csv
)
(you may want to delete the "Number.csv")
For converting XLS to CSV, this may help (I did not try that):
file
EDIT
if "numbers" is in another column
a single line consists of several "tokens", delimited by one or more delimiters (in this case the comma)
You can take token 1, token 2, token 3 etc. "*" means "the rest of the line"
So, if Numbers is in Column 2, write
for /F "tokens=1,2,* delims=," %%a in (file.csv) do (echo %%a,%%b,%%c >>%%b.csv )
(note that it writes to the file %%b.csv (number is column 2)
or if you want to change the order:
for /F "tokens=1,2,* delims=," %%a in (file.csv) do echo %%b,%%a,%%c
(note the order of a, b and c)
if you would use 26 tokens, they will be named %%a to %%z
you can expand it to "tokens=1,2,3,4,5,6,7" etc, when you need it to rearange the order.
Edit2:
for the headers, simply add one line before the "for"-line:
echo Number,Title,Third Column >file.csv
Thee >
creates a new file (deleting a existing file), while >>
appends to the file