Parse tab delimited text file

这一生的挚爱 提交于 2019-12-02 04:21:42

Your code works fine for me, but maybe try this shortened version?

@echo off
for /F "tokens=1,5*" %%i in (myFile.dat) do (
echo %%i >>Entity.txt
echo %%j >>Account.txt
)

While I would recommend using the shortened version by Bali C, the reason the code above might be stopping after the first line is because the goto :eof or exit command is not at the end of the :doSomething function.

@echo off & setlocal 
For /F "tokens=1,5*" %%i in (myFile.dat) do call :doSomething "%%i" "%%j"
goto :eof 

:doSomething 
Set VAR1=%1
Set VAR2=%2
@echo %VAR1%>>Entity.txt
@echo %VAR2%>>Account.txt
goto :eof

Or if Extensions are disabled, it would be outputting the following error message:

/F was unexpected at this time.

To resolve this add EnableExtensions to your setlocal command.

@echo off & setlocal EnableExtensions

your code is working fine, check the output below.

Account.txt

"COL5"

"012"

"123"

""

Entity.txt

"COL1"

"123"

"234"

"etc"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!