如何阅读制表符分隔的文本文件 [英] How to read tab deliminated text file

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

问题描述

我有像这样的标签文本文件



a [tab] [tab] 40550 [tab] 15415 [tab] 15411 [tab] 54115

b [tab] [tab] 40550 [tab] 15415 [tab] 15411 [tab] 54115

c [tab] [tab] 40550 [tab] 15415 [tab] 15411 [tab] 54115



i需要写新文本文件



name =a.tifaddress = 40550, 15415,15411,54115

name =a.tifaddress = 40550,15415,15411,54115

name =a.tifaddress = 40550,15415, 15411,54115





任何人都可以帮助我,或者通过一个字段值来提供代码,就像那样的40550。 ...

解决方案

请参阅: http://msdn.microsoft.com/en-us/library/system.string.split%28v=vs.110%29.aspx [ ^ ]。



-SA


最简单的方法是使用CSV阅读器 - C#CSV阅读器和写入器 [ ^ ]并将其配置为TAB而不是COMMA作为分隔符值。



或者,只需将所有行读入一个字符串数组,并使用String.Split来分解循环中的每一行。


看看这个代码项目文章从分隔文本文件中填写数据集 [ ^ ]



如何写出数据取决于你... e .g。 textwriter [ ^ ]

i have tab deliminated text file like that

a[tab][tab]40550[tab]15415[tab]15411[tab]54115
b[tab][tab]40550[tab]15415[tab]15411[tab]54115
c[tab][tab]40550[tab]15415[tab]15411[tab]54115

i need to write new text file as

name="a.tif" address=40550,15415,15411,54115
name="a.tif" address=40550,15415,15411,54115
name="a.tif" address=40550,15415,15411,54115


can any one help me please or give code for get on by one field value like a then 40550 like that....

解决方案

Please see: http://msdn.microsoft.com/en-us/library/system.string.split%28v=vs.110%29.aspx[^].

—SA


Easiest way is to use a CSV reader - C# CSV Reader and Writer[^] for example - and configure it for a TAB instead of a COMMA as the separator value.

Alternatively, just read all the lines into an array of strings, and use String.Split to break up each line in a loop.


Have a look at this codeproject article Fill a DataSet from delimited text files[^]

How you write the data out is up to you ...e .g. textwriter[^]


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

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