Script attached in zip file below.
- Basic fancy formats ....
- Format lists and arrays
- 6.1. string — Common string operations — Python 3.5.1 documentation
- Python mini-formatting language
This is a work in progress
This example shows how to generate column formats from the data itself and how to generate a header from the tabular information. The simplest way to obtain a useful table for manipulation in other software is to use the FeatureclassToNumPyArray or TableToNumPyArray methods in arcpy. A sample output for such a table is shown in the example.
In the example below, the following procedure was used:
- the first row of the table is used to obtain the column widths and data type
- an appropriate format string was used to create the column structure... NOTE. as in the previous example a vertical bar, |, is used to denote the column positional start and the underscore, _, to denote preceding or trailing spaces.
- the format string and the number of columns in the table creates the line format,
- combining that information with column width gives a resultant column format
- an option to use the maximum size between the column name and data size is used to modify the values of column width.
- finally... a column header...generated from the input data... is produced and the line is printed.
The next example will delve into how to do this all in one swoop giving the option to use column widths based upon data size with the columns and/or whether to maintain column size, alignment, record delimiters and whether to include ancillary information related to the table.