You can use pandas. They are great for reading csv files, tab delimited files etc. Pandas will almost all the time read the data type correctly and put them in an numpy array when accessed using rows/columns as demonstrated.
I used this tab delimited 'test.txt' file:
bbbbffdd 434343 228 D
bbbWWWff 43545343 289 E
ajkfbdafa 2345345 2312 F
Here is the pandas code. Your file will be read in a nice dataframe using one line in python. You can change the 'sep' value to anything else to suit your file.
import pandas as pd
X = pd.read_csv('test.txt', sep="", header=None)
Then try:
print X
0 1 2 3
0 bbbbffdd 434343 228 D
1 bbbWWWff 43545343 289 E
2 ajkfbdafa 2345345 2312 F
print X[0]
0 bbbbffdd
1 bbbWWWff
2 ajkfbdafa
print X[2]
0 228
1 289
2 2312
print X[1][1:]
1 43545343
2 2345345
You can add column names as:
X.columns = ['random_letters', 'number', 'simple_number', 'letter']
And then get the columns as:
X['number'].values
array([ 434343, 43545343, 2345345])
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…