Java Read Text Column function similar to ReadLine()
I have a text file containing vector information by pin. It looks like this:
PHP Code:
xxxxxxxxxxxxxxxxxxxx
pppppppppppppppppppp
iiiiiiiiiiiiiiiiiiii
nnnnnnnnnnnnnnnnnnnn
12345689111111111122
012345678901
CountPatAdr
(
Main
)(
Main
)
101000000000000010XXXX
201000000000000010XXXX
301000000000000010XXXX
401000000000000010XXXX
501000000000000010XXXX
601000000000000010XXXX
701000000000000010XXXX
801000000000000010XXXX
901000000000000010XXXX
1001000000000000010XXXX
1101000000000000010XXXX
1201000000000000010XXXX
1301000000000000010XXXX
1401000000000000010XXXX
1501000000000000010XXXX
1601000000000000010XXXX
...
I want to extract the information column by column. So I would like to be able to write or store each pin by line such as:
xpin1 11111...
xpin2 10000...
xpin3 10000...
Basically, what I am looking for is exactly the Java readLine() function described here:
http://java.sun.com/javase/6/docs/ap...redReader.html
but instead of reading a text file line-by-line. I want to read column by column. Anyone know of such a function or way to do this?
要实现这个算法,需要进行集合成员的拼接和转换。java做这种集合式的运算不难,但代码繁琐比较麻烦;使用 R 或 python 都比较容易,但没法被 java 主程序集成。用 SPL 也容易完成,并且可以被 java 主程序调用 (参考Java 如何调用 SPL 脚本),代码如下:
A | |
1 | =file("source.txt").read@n() |
2 | =A1.to(2,6) |
3 | =A1.to(14,) |
4 | =A2.regex("(.*) (.*)";a,b).(b) |
5 | =A4.new(mid(~,1,1),mid(~,2,1),mid(~,3,1),mid(~,4,1),mid(~,5,1),mid(~,6,1),mid(~,7,1),mid(~,8,1),mid(~,9,1),mid(~,10,1),mid(~,11,1),mid(~,12,1),mid(~,13,1),mid(~,14,1),mid(~,15,1),mid(~,16,1),mid(~,17,1),mid(~,18,1),mid(~,19,1),mid(~,20,1)) |
6 | =A3.regex("(.*) (.*)";a,b).(b) |
7 | =A6.new(mid(~,1,1),mid(~,2,1),mid(~,3,1),mid(~,4,1),mid(~,5,1),mid(~,6,1),mid(~,7,1),mid(~,8,1),mid(~,9,1),mid(~,10,1),mid(~,11,1),mid(~,12,1),mid(~,13,1),mid(~,14,1),mid(~,15,1),mid(~,16,1),mid(~,17,1),mid(~,18,1),mid(~,19,1),mid(~,20,1)) |
8 | =A5|A7 |
9 | =A8.fno().(A8.field(~).concat()) |
A1:读取source.txt文件内容,将每一行返回成字符串。
A2:取序列第2-6行数据组成新序列。
A3:取14行之后的数据组成新序列。
A4:正则匹配出需要的数据。
A5:将A4拆分成二维表。
A6:正则匹配出需要的数据。
A7:将A6拆分成二维表。
A8:合并2个二维表。
A9:将每列合并成字符串。