TableExportOptions Class
TableExportOptions objects hold complete
descriptions of options for exporting tables to fixed-column-width or column-delimited
text files. TableExportOptions objects have fields that are settable by the
user to create marker lines of various styles. New TableExportOptions
objects are created by calls to TableExportOptions() (e.g. myOptions =
TableExportOptions() ). TableExportOptions fields are described below.
TableExportOptions Fields
|
Field |
Type |
Description |
Default |
|
delimiter |
string (one character) |
Placed between fields if fixedWidthCol is Constants.FALSE |
‘\t’ (tabcharacter) |
|
quotedStrings |
0/1 |
Specifies whether to enclose text in quotes |
Constants.FALSE |
|
title |
string |
Title of the table |
None |
|
fixedWidthCols |
0/1 |
Specifies whether fields are exported as fixed-width columns or fields separated by delimiter |
Constants.FALSE |
|
columnHeader |
0/1 |
Specifies whether the column headers are to be exported |
Constants.TRUE |
|
rowHeader |
0/1 |
Specifies whether the row headers are to be exported |
Constants.FALSE |
|
gridLines |
0/1 |
Specifies whether the table will be exported with text “lines” between the rows and columns |
Constants.FALSE |
The script in the example below creates a table from two DSS data sets and exports the table as a comma-separated-value text file.
|
Example: Filling, Displaying and Exporting a Table from hec.heclib.dss import * # for DSS from hec.script import * # for Tabulate file = “C:/mydb.dss" # specify the DSS file dssfile = HecDss.open(file) # open the file # read 2 records
stage = dssfile.get("//AXEMA/STAGE/01OCT2001/1HOUR/OBS/")
flow = dssfile.get("//AXEMA/FLOW/01OCT2001/1HOUR/OBS/")
theTable = Tabulate.newTable() # create the table
theTable.setTitle("Test Table") # set the table title
theTable.setLocation(5000,5000) # set the location of the table of the screen theTable.addData(flow) # add the data theTable.addData(stage) theTable.showTable() # show the table flowCol = theTable.getColumn(flow) # adjust columns stageCol = theTable.getColumn(stage) flowWidth = theTable.getColumnWidth(flow) stageWidth = theTable.getColumnWidth(stage) theTable.setColumnPrecision(flowCol, 0) theTable.setColumnPrecision(stageCol, 2) theTable.setColumnWidth(flowCol, flowWidth - 10) theTable.setColumnWidth(stageCol, stageWidth + 10) opts = TableExportOptions() # get new export options opts.delimiter = “,” # delimit with commas opts.title = “My Table” # set the title fileName = “c:/table.txt” # set the output file name theTable.export(fileName, opts) # export to the file theTable.close() # close |