Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- numpy.loadtxt(
- fname,
- dtype=<type 'float'>,
- comments='#',
- delimiter=None,
- converters=None,
- skiprows=0,
- usecols=None,
- unpack=False,
- ndmin=0
- )
- Load data from a text file.
- ...
- usecols : sequence, optional Which columns to read, with 0 being
- the first. For example, usecols = (1,4,5) will extract the
- 2nd, 5th and 6th columns. The default, None, results in all
- columns being read.
- 100 test1
- 200 test2
- 300 test3
- $ python -c "import numpy as np;np.loadtxt('test.txt')"
- Traceback (most recent call last):
- ...
- items = [conv(val) for (conv, val) in zip(converters, vals)]
- ValueError: could not convert string to float: test1
- $ python -c "import numpy as np;print np.loadtxt('test.txt', usecols=(0,))"
- [ 100. 200. 300.]
- numpy.loadtxt('input_file.txt', dtype=str, usecols=(1,2,3,4))
- array([['MAX', 'Footprint', 'Center-X', 'Center-Y'],
- ['"100-0009"', '"1206', '-', 'CAPACITOR"'],
- ['"100-0009"', '"1206', '-', 'CAPACITOR"'],
- ['"100-0009"', '"1206', '-', 'CAPACITOR"'],
- ['"100-0009"', '"1206', '-', 'CAPACITOR"'],
- ['"100-0009"', '"1206', '-', 'CAPACITOR"'],
- ['"100-0009"', '"1206', '-', 'CAPACITOR"']],
- dtype='|S10')
Add Comment
Please, Sign In to add comment