从文本文件中获取单个字段 [英] get a single field from a text file
本文介绍了从文本文件中获取单个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含5列的文本文件
i想要提取第一列的所有条目怎么可能想到使用split / string tokenizer
i have a text file with 5 columns
i want to extract all the entry of first column how can that be possible thought of using split/string tokenizer
推荐答案
这取决于你的文件格式。
逐行阅读文件:
- 如果字段是 delimited 然后你可以使用字符串类的
split
方法。- 另一方面,如果你有固定宽度字段,然后你可以使用
substring
方法。
It depends on the format of your file.
Reading the file line by line:
- If the fields are delimited then you may use the
split
method of the string class.- On the other hand, if you have fixed width fields then you may use the
substring
method.
这篇关于从文本文件中获取单个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文