0

I want to print all the rows in the table. "stat_data" list has 323 items which i want to print on console.

Used the below code to do so.

from astropy.table import Table, Column
t = Table(rows=stat_data, names=('Redacted Term', 'Length', 'File', 'Type'))
print(t)

But it's printing only fewer rows, not all of them. Help me print all the rows.

Output of the above code is as below

    Redacted Term Length             File              Type
    ------------- ------ ---------------------------- ------
    Trump      5                       1.html  names
    4909090909     10 otherfiles/sample-output.txt phones
    3235294117     10 otherfiles/sample-output.txt phones
    5957446808     10 otherfiles/sample-output.txt phones
    8518518518     10 otherfiles/sample-output.txt phones
    3255813953     10 otherfiles/sample-output.txt phones
    5227272727     10 otherfiles/sample-output.txt phones
    3076923076     10 otherfiles/sample-output.txt phones
    0555555555     10 otherfiles/sample-output.txt phones
    5384615384     10 otherfiles/sample-output.txt phones
    4210526315     10 otherfiles/sample-output.txt phones
    7777777777     10 otherfiles/sample-output.txt phones
    3181818181     10 otherfiles/sample-output.txt phones
    5869565217     10 otherfiles/sample-output.txt phones
    1153846153     10 otherfiles/sample-output.txt phones
    4347826086     10 otherfiles/sample-output.txt phones
    2043010752     10 otherfiles/sample-output.txt phones
    8260869565     10 otherfiles/sample-output.txt phones
    6315789473     10 otherfiles/sample-output.txt phones
    4583333333     10 otherfiles/sample-output.txt phones
      ...    ...                          ...    ...
    William      7             otherfiles/a.txt  names
    Mastrosimone     12             otherfiles/a.txt  names
    William      7             otherfiles/a.txt  names
     Tell      4             otherfiles/a.txt  names
    Oveture      7             otherfiles/a.txt  names
    Gioachino      9             otherfiles/a.txt  names
    Rossini      7             otherfiles/a.txt  names
    Oklahoma      8             otherfiles/a.txt places
    Sydney      6             otherfiles/a.txt places
    Dallas      6             otherfiles/a.txt places
    Texas      5             otherfiles/a.txt places
      San      3             otherfiles/a.txt places
    Fransisco      9             otherfiles/a.txt places
      USA      3             otherfiles/a.txt places
    Cupertino      9             otherfiles/a.txt places
    Cupertino      9             otherfiles/a.txt places
       CA      2             otherfiles/a.txt places
    Vinayak      7             otherfiles/2.txt  names
    Sudhindra      9             otherfiles/3.txt  names
    Sudhindra      9             otherfiles/3.txt  names
    Length = 323 rows
Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
Pramod
  • 41
  • 1
  • 5

2 Answers2

1

The pprint method allows multiple lines in an astropy Table to be printed without truncation. For example, if blat is a Table and you want to print 100 lines:

nlines = 100
blat.pprint(nlines) 

To print all of the lines:

nlines = len(blat) + 2
blat.pprint(nlines) 

where the +2 is typically needed to account for the header rows.

0

Iterating over a table and printing each row is an easy way to get around the truncation that Python sometimes applies to long outputs.

Given t is a Table from astropy.table, try this:

for row in t:
    print(row.as_void())

Here, row is a Row object, and as_void() produces the raw data for that row.

andrew_reece
  • 18,690
  • 2
  • 27
  • 54