Reputation: 684
I'm having a bit of a strange problem. I got a .csv file that I want to process. The script works fine and I didn't have any problems testing with a small .csv file but when I try to run the batch on the original .csv (around 100k lines, 7MB) for some reason the script only runs AFTER I open the file in Excel.
The script completes just fine apart from not running without opening Excel so I'm not really sure what is going on. Especially since it does run automatically with a smaller file.
setlocal
set "file=test2.csv"
set "fileout=output.csv"
set /p "var="<"%file%" >nul
>"%fileout%" echo.%var%,test_column
for /f "skip=1 delims=" %%a in ('type "%file%"') do (
>>%fileout% echo.%%a,test_value
)
Upvotes: 0
Views: 71
Reputation: 14290
Change your code to read the file directly instead of reading the output from the TYPE
command. Also enclose all your code so that it keep the file open for writing.
@echo off
set "file=input.csv"
set "fileout=output.csv"
set /p "var="<"%file%"
(
echo.%var%,test_column
for /f "usebackq skip=1 delims=" %%a in ("%file%") do echo.%%a,test_value
)>"%fileout%"
Upvotes: 1