title: How to break large cell into multiple lines and adjust table?
body: <p>I'm using <a href="https://github.com/thombashi/pytablewriter" rel="nofollow noreferrer">pytablewriter</a> to write data from postgres to a rst grid table. My code is:</p>
  <pre class="lang-py prettyprint-override"><code>from pytablewriter import RstGridTableWriter as RST
  import psycopg2
  
  if __name__ == '__main__':
      with connection.cursor(name='foo') as cursor:
          cursor.itersize = 100000
          cursor.execute(query)
  
          for raw_row in cursor:
              row = [
                  raw_row[0],
                  raw_row[1],
                  raw_row[2],
                  ', '.join([item for item in raw_row[3] if item])
              ]
  
              matrix.append(row)
  
      writer = RST(
          table_name='DocTable',
          headers=['col1', 'col2', 'col3', 'col4'],
          value_matrix=matrix
      )
  
      writer.dump('./sample.rst')
  </code></pre>
  <p>The last value of each row fetched is a list of strings. For every iteration, the code above turns the list of strings into a comma separated string. That string can be potentially large and result in a large column.</p>
  <p>I'd like to know how to output a table with fixed width for each column and break large columns into multiple lines. Example:</p>
  <p>Cell:
  <code>&quot;Lorem,ipsum,dolor,sit,amet,consectetur,adipiscing,elit,sed,do,eiusmod,tempor,incididunt,ut,labore,et,dolore,magna,aliqua.,Ut,enim,ad,minim,veniam,quis,nostrud,exercitation,ullamco,laboris,nisi,ut,aliquip,ex,ea,commodo,consequat&quot;</code></p>
  <p>Turns into:</p>
  <pre><code>'Lorem,'
  'ipsum,'
  'dolor,'
  'sit,'
  'amet,'
  'consectetur,'
  'adipiscing,'
  'elit,'
  'sed,'
  'do,'
  'eiusmod,'
  'tempor,'
  'incididunt,'
  'ut,'
  'labore,'
  'et,'
  'dolore,'
  'magna,'
  'aliqua.,'
  'Ut,'
  'enim,'
  'ad,'
  'minim,'
  'veniam,'
  'quis,'
  'nostrud,'
  'exercitation,'
  'ullamco,'
  'laboris,'
  'nisi,'
  'ut,'
  'aliquip,'
  'ex,'
  'ea,'
  'commodo,'
  'consequat'
  </code></pre>
  <p>And all other cells are properly adjusted as well.</p>
  <p>I've tried to write it as <code>',\n'.join([item for item in raw_row[3] if item])</code> but does not work.</p>