5.1. Table Writer Classes

5.1.1. CSV table writer classes

5.1.1.1. CSV writer

class pytablewriter.CsvTableWriter

Bases: pytablewriter.writer.text._text_writer.TextTableWriter

A table writer class for character separated values format. The default separated character is a comma (",").

Example:CSV
close()

Close the current stream.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.1.2. TSV writer

class pytablewriter.TsvTableWriter

Bases: pytablewriter.writer.text._csv.CsvTableWriter

A table writer class for tab separated values (TSV) format.

Example:TSV
close()

Close the current stream.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.2. LTSV writer

class pytablewriter.LtsvTableWriter

Bases: pytablewriter.writer.text._csv.CsvTableWriter

A table writer class for Labeled Tab-separated Values (LTSV) format.

close()

Close the current stream.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream with Labeled Tab-separated Values (LTSV) format. Invalid characters in labels/data are removed.

Raises:pytablewriter.EmptyHeaderError – If the header_list is empty.
Example:example-ltsv-table-writer
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.3. Elasticsearch writer

class pytablewriter.ElasticsearchWriter

Bases: pytablewriter.writer._table_writer.AbstractTableWriter

A table writer class for Elasticsearch.

Dependency Packages:
 
index_name

Alias attribute for table_name.

document_type

Specify document type for indices. Defaults to "table".

write_table()

Create an index and put documents for each row to Elasticsearch.

You need to pass an elasticsearch.Elasticsearch instance to stream before calling this method. table_name/index_name used as the creating index name, invalid characters in the name are replaced with underscore ('_'). Document data types for documents are automatically detected from the data.

Raises:ValueError – If the stream has not elasticsearch.Elasticsearch instance.
Example:Elasticsearch
close()

Close the current stream.

from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_table()

Write a table to the stream.

write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.4. Excel writer classes

5.1.4.1. Xlsx table writer

class pytablewriter.ExcelXlsxTableWriter

Bases: pytablewriter.writer.binary._excel.ExcelTableWriter

A table writer class for Excel file format: .xlsx (newer or equal to Office 2007).

write_table()

Write a table to the current opened worksheet.

Raises:IOError – If failed to write data to the worksheet.
Examples:Excel Sheet

Note

Specific values in the tabular data are converted when writing:

  • None: written as an empty string
  • inf: written as Inf
  • nan: written as NaN
close()

Close the current workbook.

first_data_col
Returns:Index of the first column of the table.
Return type:int

Note

This attributes available after execution of the write_table() method.

first_data_row
Returns:Index of the first row of the data (table body).
Return type:int

Note

This attributes available after execution of the write_table() method.

first_header_row
Returns:Index of the first row of the header.
Return type:int

Note

This attributes available after execution of the write_table() method.

from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value)

Set following attributes from TableData

And create worksheet named from table_name ABC if not existed yet.

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

last_data_col
Returns:Index of the last column of the table.
Return type:int

Note

This attributes available after execution of the write_table() method.

last_data_row
Returns:Index of the last row of the data (table body).
Return type:int

Note

This attributes available after execution of the write_table() method.

last_header_row
Returns:Index of the last row of the header.
Return type:int

Note

This attributes available after execution of the write_table() method.

make_worksheet(sheet_name)

Make a worksheet to the current workbook.

Parameters:sheet_name (str) – Name of the worksheet to create. Name of the work sheet automatically decided (like "Sheet1") if the sheet_name is empty.
open(file_path)

Open an Excel workbook file.

Parameters:file_path (str) – Excel workbook file path to open.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_table()

Write a table to the stream.

write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.4.2. Xls table writer

class pytablewriter.ExcelXlsTableWriter

Bases: pytablewriter.writer.binary._excel.ExcelTableWriter

A table writer class for Excel file format: .xls (older or equal to Office 2003).

xlwt package required to use this class.

write_table()

Write a table to the current opened worksheet.

Raises:IOError – If failed to write data to the worksheet.

Note

Specific values in the tabular data are converted when writing:

  • None: written as an empty string
  • inf: written as Inf
  • nan: written as NaN
close()

Close the current workbook.

first_data_col
Returns:Index of the first column of the table.
Return type:int

Note

This attributes available after execution of the write_table() method.

first_data_row
Returns:Index of the first row of the data (table body).
Return type:int

Note

This attributes available after execution of the write_table() method.

first_header_row
Returns:Index of the first row of the header.
Return type:int

Note

This attributes available after execution of the write_table() method.

from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value)

Set following attributes from TableData

And create worksheet named from table_name ABC if not existed yet.

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

last_data_col
Returns:Index of the last column of the table.
Return type:int

Note

This attributes available after execution of the write_table() method.

last_data_row
Returns:Index of the last row of the data (table body).
Return type:int

Note

This attributes available after execution of the write_table() method.

last_header_row
Returns:Index of the last row of the header.
Return type:int

Note

This attributes available after execution of the write_table() method.

make_worksheet(sheet_name)

Make a worksheet to the current workbook.

Parameters:sheet_name (str) – Name of the worksheet to create. Name of the work sheet automatically decided (like "Sheet1") if the sheet_name is empty.
open(file_path)

Open an Excel workbook file.

Parameters:file_path (str) – Excel workbook file path to open.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_table()

Write a table to the stream.

write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.5. LaTeX writer classes

5.1.5.1. LaTeX matrix writer

class pytablewriter.LatexMatrixWriter

Bases: pytablewriter.writer.text._latex.LatexWriter

A matrix writer class for LaTeX environment.

write_table()

Write a table to the stream with LaTeX array environment.

Example:LaTeX matrix
close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.5.2. LaTeX table writer

class pytablewriter.LatexTableWriter

Bases: pytablewriter.writer.text._latex.LatexWriter

A matrix writer class for LaTeX environment.

write_table()

Write a table to the stream with LaTeX array environment.

Example:LaTeX table
close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.6. Markup language writer classes

5.1.6.1. HTML table writer

class pytablewriter.HtmlTableWriter

Bases: pytablewriter.writer.text._text_writer.TextTableWriter

A table writer class for HTML format.

close()

Close the current stream.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream with HTML table format.

Example:HTML

Note

  • None is not written
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.6.2. MediaWiki table writer

class pytablewriter.MediaWikiTableWriter

Bases: pytablewriter.writer.text._text_writer.TextTableWriter

A table writer class for MediaWiki format.

Example:MediaWiki
close()

Close the current stream.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.6.3. Markdown table writer

class pytablewriter.MarkdownTableWriter

Bases: pytablewriter.writer.text._text_writer.IndentationTextTableWriter

A table writer class for Markdown format.

close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream with Markdown table format.

Raises:pytablewriter.EmptyHeaderError – If the header_list is empty.
Example:Markdown

Note

  • None values are written as an empty string
  • Vertical bar characters ('|') in table items are escaped
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.7. JSON writer class

class pytablewriter.JsonTableWriter

Bases: pytablewriter.writer.text._text_writer.IndentationTextTableWriter

A table writer class for JSON format.

write_table()

Write a table to the stream with JSON format.

Raises:pytablewriter.EmptyHeaderError – If the header_list is empty.
Examples:JSON

Note

Specific values in the tabular data are converted when writing:

  • None: written as null
  • inf: written as Infinity
  • nan: written as NaN
close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.8. Line-delimited JSON(LDJSON) writer class

class pytablewriter.JsonTableWriter

Bases: pytablewriter.writer.text._text_writer.IndentationTextTableWriter

A table writer class for JSON format.

write_table()

Write a table to the stream with JSON format.

Raises:pytablewriter.EmptyHeaderError – If the header_list is empty.
Examples:JSON

Note

Specific values in the tabular data are converted when writing:

  • None: written as null
  • inf: written as Infinity
  • nan: written as NaN
close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.9. Source code writer classes

5.1.9.1. JavaScript writer

class pytablewriter.JavaScriptTableWriter

Bases: pytablewriter.writer.text.sourcecode._sourcecode.SourceCodeTableWriter

A table writer for class JavaScript format.

variable_declaration

JavaScript variable declarations type. The value must be either "var", "let" or "const". Defaults to "const".

write_table()

Write a table to the stream with JavaScript format. The tabular data are written as a nested list variable definition.

Raises:
Example:

JavaScript Code

Note

Specific values in the tabular data are converted when writing:

  • None: written as null
  • inf: written as Infinity
  • nan: written as NaN
  • datetime.datetime instances determined by is_datetime_instance_formatting attribute:
close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

variable_name

Return a valid variable name that converted from the table_name.

Returns:A variable name.
Return type:str
write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.9.2. NumPy table writer

class pytablewriter.NumpyTableWriter

Bases: pytablewriter.writer.text.sourcecode._python.PythonCodeTableWriter

A table writer class for NumPy source code format.

write_table()

Write a table to the stream with NumPy format. The tabular data are written as a variable definition of numpy.array.

Raises:
Example:

NumPy array

Note

Specific values in the tabular data are converted when writing:

  • None: written as None
  • inf: written as numpy.inf
  • nan: written as numpy.nan
  • datetime.datetime instances determined by is_datetime_instance_formatting attribute:
close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

variable_name

Return a valid variable name that converted from the table_name.

Returns:A variable name.
Return type:str
write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.9.3. Pandas DataFrame writer

class pytablewriter.PandasDataFrameWriter

Bases: pytablewriter.writer.text.sourcecode._numpy.NumpyTableWriter

A writer class for Pandas DataFrame format.

import_pandas_as

Specify pandas module import name. Defaults to "pd".

import_numpy_as

Specify numpy module import name. Defaults to "np".

write_table()

Write a table to the stream with Pandas DataFrame format. The tabular data are written as a pandas.DataFrame class instance definition.

Raises:
Example:

Pandas DataFrame

Note

Specific values in the tabular data are converted when writing:

  • None: written as None
  • inf: written as numpy.inf
  • nan: written as numpy.nan
  • datetime.datetime instances determined by is_datetime_instance_formatting attribute:
close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

variable_name

Return a valid variable name that converted from the table_name.

Returns:A variable name.
Return type:str
write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.9.4. Python table writer

class pytablewriter.PythonCodeTableWriter

Bases: pytablewriter.writer.text.sourcecode._sourcecode.SourceCodeTableWriter

A table writer class for Python source code format.

write_table()

Write a table to the stream with Python format. The tabular data are written as a nested list variable definition for Python format.

Raises:
Example:

Python Code

Note

Specific values in the tabular data are converted when writing:

  • None: written as None
  • inf: written as float("inf")
  • nan: written as float("nan")
  • datetime.datetime instances determined by is_datetime_instance_formatting attribute:
close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

variable_name

Return a valid variable name that converted from the table_name.

Returns:A variable name.
Return type:str
write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.10. reStructuredText writer classes

5.1.10.1. reStructuredText CSV table writer

class pytablewriter.RstCsvTableWriter

Bases: pytablewriter.writer.text._rst.RstTableWriter

A table class writer for reStructuredText CSV table format.

close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream with reStructuredText CSV table format.

Raises:pytablewriter.EmptyTableDataError – If the header_list and the value_matrix is empty.
Example:reStructuredText CSV Table

Note

  • None values are written as an empty string
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.10.2. reStructuredText grid table writer

class pytablewriter.RstGridTableWriter

Bases: pytablewriter.writer.text._rst.RstTableWriter

A table writer class for reStructuredText Grid Tables format.

write_table()

Write a table to the stream with reStructuredText grid tables format.

Example:reStructuredText Grid Tables

Note

  • None values are written as an empty string
close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.10.3. reStructuredText simple table writer

class pytablewriter.RstSimpleTableWriter

Bases: pytablewriter.writer.text._rst.RstTableWriter

A table writer class for reStructuredText Simple Tables format.

write_table()

Write a table to the stream with reStructuredText simple tables format.

Example:reStructuredText Simple Tables

Note

  • None values are written as an empty string
close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.11. Space aligned table writer

class pytablewriter.SpaceAlignedTableWriter

Bases: pytablewriter.writer.text._csv.CsvTableWriter

A table writer class for space aligned format.

write_table()

Write a table to the stream with space aligned format.

Example:example-space-aligned-table-writer
close()

Close the current stream.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.12. SQLite writer class

class pytablewriter.SqliteTableWriter

Bases: pytablewriter.writer.binary._interface.AbstractBinaryTableWriter

A table writer class for SQLite database.

write_table()

Write a table to a SQLite database.

Raises:
Example:

SQLite

close()

Close the current stream.

from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

open(file_path)

Open a SQLite database file.

Parameters:file_path (str) – SQLite database file path to open.
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_table()

Write a table to the stream.

write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.13. TOML table writer class

class pytablewriter.TomlTableWriter

Bases: pytablewriter.writer.text._text_writer.TextTableWriter

A table writer class for TOML data format.

close()

Close the current stream.

dumps()
Returns:Rendered tabular text.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream with TOML format.

Raises:
Example:

TOML

write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

5.1.14. Base table writer class

class pytablewriter.writer._table_writer.TableWriterInterface

Bases: object

Interface class for writing a table.

format_name
Returns:Format name for the writer.
Return type:str
support_split_write
Returns:True if the writer supported iterative table writing (write_table_iter method).
Return type:bool
write_table()

Write a table to the stream.

write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

class pytablewriter.writer._table_writer.AbstractTableWriter

Bases: pytablewriter.writer._interface.TableWriterInterface

An abstract base class of table writer classes.

stream

Stream to write tables. You can use arbitrary stream which supported write method such as sys.stdout, file stream, StringIO, and so forth. Defaults to sys.stdout.

is_write_header

Write headers of a table if the value is True.

is_padding

Padding for each item in the table if the value is True.

is_escape_html_tag

Escape HTML tags in cells in the table if the value is True.

iteration_length

The number of iterations to write a table. This value used in write_table_iter() method. (defaults to -1 which means number of iterations is indefinite)

write_callback

The value expected to a function. The function called when for each of the iteration of writing a table completed. (defaults to None) Example, callback function definition is as follows:

def callback_example(iter_count, iter_length):
    print("{:d}/{:d}".format(iter_count, iter_length))

Arguments that passed to the callback is:

  • first argument: current iteration number (start from 1)
  • second argument: a total number of iteration
close()

Close the current stream.

format_name
Returns:Format name for the writer.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

support_split_write
Returns:True if the writer supported iterative table writing (write_table_iter method).
Return type:bool
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_table()

Write a table to the stream.

write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

class pytablewriter.writer.text._text_writer.TextTableWriter

Bases: pytablewriter.writer._table_writer.AbstractTableWriter, pytablewriter.writer.text._interface.TextWriterInterface

A base class for table writer with text formats.

column_delimiter

A column delimiter of a table.

char_left_side_row

A character of a left side of a row.

char_right_side_row

A character of a right side of a row.

char_cross_point

A character of the crossing point of column delimiter and row delimiter.

char_opening_row

A character of the first line of a table.

char_header_row_separator

A character of a separator line of the header and the body of the table.

char_value_row_separator

A character of a row separator line of the table.

char_closing_row

A character of the last line of a table.

is_write_header_separator_row

Write a header separator line of the table if the value is True.

is_write_value_separator_row

Write row separator line(s) of the table if the value is True.

is_write_opening_row

Write an opening line of the table if the value is True.

is_write_closing_row

Write a closing line of the table if the value is True.

is_write_null_line_after_table

Write a blank line of after writing a table if the value is True.

table_char

Character attributes that compose a table

close()

Close the current stream.

dumps()
Returns:Rendered tabular text.
Return type:str
format_name
Returns:Format name for the writer.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

support_split_write
Returns:True if the writer supported iterative table writing (write_table_iter method).
Return type:bool
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.

class pytablewriter.writer.text._text_writer.IndentationTextTableWriter

Bases: pytablewriter.writer.text._text_writer.TextTableWriter, pytablewriter.writer.text._interface.IndentationInterface

A base class for table writer with indentation text formats.

indent_string

Indentation string for each level.

close()

Close the current stream.

dec_indent_level()

Decrement the current indent level.

dumps()
Returns:Rendered tabular text.
Return type:str
format_name
Returns:Format name for the writer.
Return type:str
from_csv(csv_source, delimiter=u', ')

Set tabular attributes to the writer from a character-separated values (CSV) data source. Following attributes are set to the writer by the method:

table_name also be set if the CSV data source is a file. In that case, table_name is as same as the filename.

Parameters:

csv_source (str) – Input CSV data source either can be designated CSV text or CSV file path.

Examples:

Using CSV as tabular data source

Dependency Packages:
 
from_dataframe(dataframe)

Set tabular attributes to the writer from pandas.DataFrame. Following attributes are set to the writer by the method:

Parameters:dataframe (pandas.DataFrame) – Input dataframe.
Example:Using pandas DataFrame as tabular data source
from_tabledata(value, is_overwrite_table_name=True)

Set tabular attributes to the writer from TableData. Following attributes are configured:

TableData can be created from various data formats by pytablereader. More detailed information can be found in https://pytablereader.rtfd.io/en/latest/

Parameters:value (tabledata.TableData) – Input table data.
from_tablib(tablib_dataset)

Set tabular attributes to the writer from tablib.Dataset.

header_list

List of table header to write.

inc_indent_level()

Increment the current indent level.

set_indent_level(indent_level)

Set the current indent level.

Parameters:indent_level (int) – New indent level.
support_split_write
Returns:True if the writer supported iterative table writing (write_table_iter method).
Return type:bool
table_name

Name of the table.

tabledata
Returns:Table data.
Return type:tabledata.TableData
type_hint_list

List of type hints for each column of the tabular data. Acceptable values are as follows:

  • None (automatically detect column type from values in the column)
  • pytablewriter.Bool
  • pytablewriter.DateTime
  • pytablewriter.Dictionary
  • pytablewriter.Infinity
  • pytablewriter.Integer
  • pytablewriter.List
  • pytablewriter.Nan
  • pytablewriter.NoneType
  • pytablewriter.NullString
  • pytablewriter.RealNumber
  • pytablewriter.String

A writer converts data for each column using type-hint information before writing tables when you call write_xxx methods. If a type-hint value is not None, the writer tries to convert data for each data in a column to type-hint class. If the type-hint value is None or failed to convert data, the writer automatically detect column data type from the column data.

If type_hint_list is None, the writer detects data types for all of the columns automatically and writes a table by using detected column types. Defaults to None.

Examples:Type Hint: JavaScript Code
value_matrix

Tabular data to write.

write_null_line()

Write a null line to the stream.

write_table()

Write a table to the stream.

Note

  • None values are written as an empty string.
write_table_iter()

Write a table with iteration. “Iteration” means that divide the table writing into multiple processes. This method is useful, especially for large data. The following are premises to execute this method:

Call back function (Optional): Callback function is called when for each of the iteration of writing a table is completed. To set call back function, set a callback function to the write_callback attribute.

Raises:pytablewriter.NotSupportedError – If the class does not support this method.

Note

Following classes do not support this method: HtmlTableWriter, RstGridTableWriter, RstSimpleTableWriter. support_split_write attribute return True if the class is supporting this method.