In [1]:
%autosave 2
%matplotlib inline
import numpy as np
import pandas
In [2]:
?np.loadtxt
In [17]:
filename = 'freddi.dat'
with open(filename) as f:
print(f.readline())
table = np.genfromtxt(filename, names=True, usecols=(0,5))
print(table.shape)
print(table.dtype)
print(table[0])
print(table['t'][:5])
In [31]:
table = np.genfromtxt(
filename,
usecols=(0,5),
skip_header=10,
skip_footer=100,
comments='#',
dtype=[('a', np.float), ('b', '|U10')],
converters={5: lambda s: s.replace(b'0', b'U')}
)
print(table.shape)
print(table.dtype)
print(table[:5])
In [ ]: