解析制表符分隔文本文件 [英] Parse tab delimited text file

查看:390
本文介绍了解析制表符分隔文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过这些列的敛特定列,比如列1和5,输出到一个文本文件来解析制表符分隔的文本文件。请找到数据文件的一个例子,和code:

I need to parse a tab-delimited text file by grabbing specific columns, like columns 1 and 5, and output each of these columns into a text file. Please find an example of the data file, and the code:

数据文件:

COL1 COL2 COL3 COL4 COL5 COL6
123  345  678  890  012  234
234  456  787  901  123  345
etc

批处理文件:

@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

这个工作,但是,循环停止在第一行。

This works, however, the For loop stops on the first line.

你能不能帮我找到这个问题?

Could you help me in finding the issue?

推荐答案

您code正常工作对我来说,但也许试试这个缩短的版本?

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
)

这篇关于解析制表符分隔文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆