USGS

Isis 3.0 Developer's Reference (API)

Home

Isis::ImportPdsTable Class Reference

Import a PDS table file with a label description. More...

#include <ImportPdsTable.h>

Public Member Functions

 ImportPdsTable ()
 Default constructor.
 
 ImportPdsTable (const QString &pdsLabFile, const QString &pdsTabFile="", const QString &pdsTableName="TABLE")
 This constructor automatically loads the given label and table files.
 
 ~ImportPdsTable ()
 Destructs the ImportPdsTable object.
 
int columns () const
 Returns the number of columns in the table.
 
int rows () const
 Returns the number of rows in the table.
 
void load (const QString &pdsLabFile, const QString &pdsTabFile="")
 Loads a PDS table label and (optional) data file.
 
bool hasColumn (const QString &colName) const
 This method determines whether the PDS table has a column with the given name.
 
QString getColumnName (const unsigned int &index=0, const bool &formatted=true) const
 Returns the name of the specifed column.
 
QStringList getColumnNames (const bool &formatted=true) const
 Return the names of all the columns.
 
QString getFormattedName (const QString &colname) const
 Converts a column name to a camel-case after it has been cleansed.
 
QString getType (const QString &colName) const
 Get the type associated with the specified column.
 
bool setType (const QString &colName, const QString &dataType)
 Change the datatype for a column.
 
Table importTable (const QString &isisTableName)
 Populate a Table object with the PDS table and return it.
 
Table importTable (const QString &colNames, const QString &isisTableName)
 Populate ISIS Table with specified column(s) from ASCII table.
 
Table importTable (const QStringList &colNames, const QString &isisTableName)
 Populate ISIS Table with specific columns from ASCII table.
 

Detailed Description

Import a PDS table file with a label description.

This class ingests a PDS table and converts it to an ISIS Table object. This class can handle importing PDS tables whose data is BINARY or ASCII format.

The PDS label file should completely define the contents of a PDS table with ASCII data or BINARY data. The location of the table data is determined from a label keyword, ^TABLE (or ^NAME_TABLE). This keyword will indicate the name of the file containing the table data and the start record value where the table data begins. If the keyword only gives the start record, the table is attached to the file that contains the label. If the keyword only gives a file name, that file only contains the data for the indicated table. PDS table files have the extension *.TAB if the table data is ASCII format and *.DAT if the data is BINARY. When constructing an ImportPdsTable object, programmers can provide a different name for the PDS table file.

NOTE: Depending on the INTERCHANGE_FORMAT value, programmers should choose the appropriate methods from this class.

Example of PDS ASCII table import. Construct the ImportPdsTable object with a label name, set the data type for the specified PDS columns, and import the PDS table to an Isis3 table with the comma separtated column names. ImportPdsTable pdsTable(labelFileName, tableFileName); pdsTable.setType("ScetTimeClock", "CHARACTER"); pdsTable.setType("ShutterStatus", "CHARACTER"); pdsTable.setType("MirrorSin", "DOUBLE"); pdsTable.setType("MirrorCos", "DOUBLE"); Table isisTable = pdsTable.importTable("ScetTimeClock,ShutterStatus,MirrorSin,MirrorCos", "VIRHouseKeeping"); Example of PDS BINARY table import. If the default constructor is used, the load method must be called to pass in the label file name. The PDS table can then be imported and an Isis3 Table object is returned. ImportPdsTable pdsTable; load(labelFileName, "", pdsTableName); Table isisTable = pdsTable.importTable(isisTableName);

Author
2011-07-20 Kris Becker

Constructor & Destructor Documentation

Isis::ImportPdsTable::ImportPdsTable ( )

Default constructor.

This constructor initializes the PDS table name to TABLE.

If this constructor is used, the load() method will need to be called to set the PDS label file.

This constructor may be used for ASCII or BINARY PDS tables.

Isis::ImportPdsTable::ImportPdsTable ( const QString &  pdsLabFile,
const QString &  pdsTableFile = "",
const QString &  pdsTableName = "TABLE" 
)

This constructor automatically loads the given label and table files.

This constructor takes the name of the label file describing the PDS table, the table data file name, and the name of the PDS table object. It will extract the description of the columns and read the contents of the table data file.

If no table file is given or an empty QString is given for the table file, the table location will be read from the label file.

If no table name is given, the default name for the object is TABLE.

This constructor may be used for ASCII or BINARY PDS tables.

Parameters
pdsLabFileName of table label file
pdsTableFileName of table data file
pdsTableNameThe name of the table object in the PDS file.
Isis::ImportPdsTable::~ImportPdsTable ( )

Destructs the ImportPdsTable object.

Member Function Documentation

int Isis::ImportPdsTable::columns ( ) const

Returns the number of columns in the table.

This method can be called for ASCII or BINARY PDS tables.

Returns
The number of columns.
QString Isis::ImportPdsTable::getColumnName ( const unsigned int &  index = 0,
const bool &  formatted = true 
) const

Returns the name of the specifed column.

This method will return the name of a specified column by index. It also has the option to format the column name to Camel-Case. This will remove all left and right parens, convert white space to spaces, compress consecutive spaces to only one space. It then removes the spaces converting the next character to uppercase.

This method can be called for ASCII or BINARY PDS tables.

Parameters
indexIndex of colunm name to get.
formattedSpecifies to convert the name to Camel-Case if true, otherwise leave as is in the PDS table.
Returns
QString Returns the column name as requested

References _FILEINFO_, and Isis::toString().

QStringList Isis::ImportPdsTable::getColumnNames ( const bool &  formatted = true) const

Return the names of all the columns.

This method will return the names of all columns. It also has the option to format the column name to Camel-Case. This will remove all left and right parens, convert white space to spaces, compress consecutive spaces to only one space. It then removes the spaces converting the next character to uppercase.

This method can be called for ASCII or BINARY PDS tables.

Parameters
formattedSpecifies to convert the name to Camel-Case if true, otherwise leave as is in the PDS table.
Returns
std::vector<QString> Returns vector of all column names
QString Isis::ImportPdsTable::getFormattedName ( const QString &  colname) const

Converts a column name to a camel-case after it has been cleansed.

This method will convert a column name to camel-case after some character cleaning is performed. All white space characters as defined by the IString class are converted to spaces. Spaces are then compressed to one space. Any left/right parens are removed. Then the conversion to camel-case is performed.

Camel case always converts the first character in a QString to uppercase. Any space or '_' character are removed and the following character is converted to uppercase. All other characters are converted to lowercase.

This method can be called for ASCII or BINARY PDS tables.

Parameters
colnameColumn name to converty
Returns
QString Returns the formatted keyword

Referenced by Isis::ProcessImportPds::ImportTable().

QString Isis::ImportPdsTable::getType ( const QString &  colName) const

Get the type associated with the specified column.

This method returns the datatype associated with the specfied column. If the column does not exist, an empty QString is returned.

This method can be called for ASCII or BINARY PDS tables.

Author
kbecker (6/27/2011)
Parameters
colNameName of column to get type for
Returns
QString Returns the type of the column. If the column does not exist, an empty QString is returned.
bool Isis::ImportPdsTable::hasColumn ( const QString &  colName) const

This method determines whether the PDS table has a column with the given name.

This method can be called for ASCII or BINARY PDS tables.

Parameters
colNameA QString containing the column name.
Returns
bool Indicates whether the table has the given column.
Table Isis::ImportPdsTable::importTable ( const QString &  isisTableName)

Populate a Table object with the PDS table and return it.

This method converts PDS table data to an ISIS table.

This method can be called to import ASCII or BINARY PDS tables.

Parameters
isisTableNameName of table
Returns
Table Table containing PDS table data

References _FILEINFO_.

Referenced by Isis::ProcessImportPds::ImportTable().

Table Isis::ImportPdsTable::importTable ( const QString &  colnames,
const QString &  isisTableName 
)

Populate ISIS Table with specified column(s) from ASCII table.

This method extracts columns specified by the caller in a QString. It is typically used for a single column, but any number of columns can be provided. colnames is a comma delimited QString that contains the name of the columns that will be exported in the table.

This method should only be called for ASCII PDS tables. If needed for BINARY tables, implementation should be added and tested.

Parameters
colNamesString containing comma delimited column names to export
isisTableNameName of table to create
Returns
Table Table containing the specified columns
Table Isis::ImportPdsTable::importTable ( const QStringList colnames,
const QString &  isisTableName 
)

Populate ISIS Table with specific columns from ASCII table.

This method extracts columns specified by the caller. If the requested column does not exist, an exception is thrown.

This method should only be called for ASCII PDS tables. If needed for BINARY tables, implementation should be added and tested.

Parameters
colNamesVector column names to convert to a table.
isisTableNameName of the table to create.
Returns
Table

References _FILEINFO_.

void Isis::ImportPdsTable::load ( const QString &  pdsLabFile,
const QString &  pdsTableFile = "" 
)

Loads a PDS table label and (optional) data file.

This method will load a PDS table dataset using a label file describing the contents of the table data. The caller can provide the table data file, otherwise, the location of the table data is extracted from the ^TABLE_NAME keyword in the provided labels. The table data is then loaded.

This method needs to be called if the default constructor is used. Otherwise, it is invoked in the constructor that takes the label, table file, and table name. This method may be used to overwrite the label and table file used. When it is invoked, the current contents of the object are discarded.

This method is used for ASCII or BINARY PDS tables.

Parameters
pdsLabFileName of PDS table label file
pdsTableFileName of PDS table data file to be imported into Isis (optional)

References _FILEINFO_, Isis::FileName::baseName(), Isis::FileName::expanded(), Isis::FileName::fileExists(), Isis::FileName::name(), Isis::FileName::path(), and Isis::toInt().

int Isis::ImportPdsTable::rows ( ) const

Returns the number of rows in the table.

This method can be called for ASCII or BINARY PDS tables.

Returns
The number of rows.
bool Isis::ImportPdsTable::setType ( const QString &  colName,
const QString &  dataType 
)

Change the datatype for a column.

This method changes the data type the specified column.

This method can be called for ASCII or BINARY PDS tables.

Author
kbecker (6/27/2011)
Parameters
colNameName of column to change
dtypeNew type of column. Support types are DOUBLE, REAL, INTEGER and CHARACTER. Unsupported/unknown types are treated as CHARACTER.
Returns
bool

The documentation for this class was generated from the following files: