简体   繁体   中英

How to print all colounm elements from a .dat file for large number of data(~10,000)

Let's say I have a .dat file and try to print its first column using this code:

import numpy as np
data = np.loadtxt('d.dat', dtype='str')
a=data[:, 1]
print(a)

Now, when number of data is around 500, it prints all data. But for 5,000 numbers of data, it prints like this:

a=['1' '2' '3' .......'9' '10']

Now my question is how to print for large numbers of data like this:

a=['1' '2' '3' '4' '5' '6' '7' '8' '9' '10']

Solution from post: Print all columns and rows of a numpy array :

See the docs on print options. Specifically:

threshold : int, optional

Total number of array elements which trigger summarization rather than full repr (default 1000).

So setting threshold to np.inf means it is never summarized. np.set_printoptions(threshold=np.inf)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM