USGS

Isis 3.0 Developer's Reference (API)

Home

Isis::ImportPdsTable Class Reference
[Utility]

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

#include <ImportPdsTable.h>

List of all members.

Classes

struct  ColumnDescr

Public Member Functions

 ImportPdsTable ()
 Default constructor.
 ImportPdsTable (const std::string &labfile)
 Constructor accepts the name of the label file.
 ImportPdsTable (const std::string &labfile, const std::string &tabfile)
 Constructor accepts the name of the label and table files.
 ~ImportPdsTable ()
int columns () const
 Return the number of columns.
int rows () const
 Return numnber of rows.
void load (const std::string &labfile, const std::string &tabfile="")
 Loads a PDS table label and (optional) data file.
bool hasColumn (const std::string &colName) const
 Determine if a named column exists.
std::string getColumnName (const int &index=0, const bool &formatted=true) const
 Return the name of the specifed column.
std::vector< std::string > getColumnNames (const bool &formatted=true) const
 Return the names of all the columns.
std::string getType (const std::string &colName) const
 Get the type associated with the specified column.
bool setType (const std::string &colName, const std::string &dtype)
 Change the datatype for a column.
Table exportAsTable (const std::string &tname) const
 Populate a Table object with the PDS table and return it.
Table exportAsTable (const std::string &colNames, const std::string &tname) const
 Populate ISIS Table with specified column(s).
Table exportAsTable (const std::vector< std::string > &colNames, const std::string &tname) const
 Populate ISIS Table with specific columns.

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.

The PDS label file (*.LBL) should completely define the contents of a text file (*.TAB). The name of the text file is determined from a label keyword ^TABLE keyword. Programmers can provide a different name for the text table file.

Author:
2011-07-20 Kris Becker

Constructor & Destructor Documentation

Isis::ImportPdsTable::ImportPdsTable (  ) 

Default constructor.

Isis::ImportPdsTable::ImportPdsTable ( const std::string &  labfile  ) 

Constructor accepts the name of the label file.

This constructor takes the name of the label file describing the PDS table. It will extract the description of the columns and the name of the table data file. The table data file is also read and internalized.

Parameters:
labfile Name of table label file

References load().

Isis::ImportPdsTable::ImportPdsTable ( const std::string &  labfile,
const std::string &  tabfile 
)

Constructor accepts the name of the label and table files.

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

Parameters:
labfile Name of table label file
tabfile Name of table data file

References load().

Isis::ImportPdsTable::~ImportPdsTable (  )  [inline]

Member Function Documentation

int Isis::ImportPdsTable::columns (  )  const [inline]

Return the number of columns.

Referenced by getColumnName().

Table Isis::ImportPdsTable::exportAsTable ( const std::vector< std::string > &  colnames,
const std::string &  tname 
) const

Populate ISIS Table with specific columns.

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

Parameters:
colNames Vector column names to convert to a table.
tname Name of the table to create.
Returns:
Table

References _FILEINFO_, Isis::iException::Message(), Isis::iException::Programmer, and table.

Table Isis::ImportPdsTable::exportAsTable ( const std::string &  colnames,
const std::string &  tname 
) const

Populate ISIS Table with specified column(s).

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

Parameters:
colNames String containing comma delimited column names to export
tname Name of table to create
Returns:
Table Table containing the specified columns

References exportAsTable(), and Isis::iString::Split().

Table Isis::ImportPdsTable::exportAsTable ( const std::string &  tname  )  const

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

This method converts all the PDS table data to an ISIS table.

Parameters:
tname Name of table
Returns:
Table Table containing PDS table data

References table.

Referenced by exportAsTable().

std::string Isis::ImportPdsTable::getColumnName ( const int &  index = 0,
const bool &  formatted = true 
) const

Return 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.

Parameters:
index Index of colunm name to get.
formatted Specifies to convert the name to Camel-Case if true, otherwise leave as is in the PDS table.
Returns:
std::string Returns the column name as requested

References _FILEINFO_, columns(), Isis::iException::Message(), and Isis::iException::Programmer.

std::vector< std::string > 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.

Parameters:
formatted Specifies to convert the name to Camel-Case if true, otherwise leave as is in the PDS table.
Returns:
std::vector<std::string> Returns vector of all column names
std::string Isis::ImportPdsTable::getType ( const std::string &  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 string is returned.

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

Determine if a named column exists.

void Isis::ImportPdsTable::load ( const std::string &  labfile,
const std::string &  tabfile = "" 
)

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 name of the table data file is extracted from label in the ^TABLE keyword. The table data is then loaded.

when this method is invoked, the current contents of the object are discarded.

Parameters:
labfile Name of table label file
tabfile Name of table data file (optional)

Referenced by ImportPdsTable().

int Isis::ImportPdsTable::rows (  )  const [inline]

Return numnber of rows.

bool Isis::ImportPdsTable::setType ( const std::string &  colName,
const std::string &  dtype 
)

Change the datatype for a column.

This method changes the data type the specified column.

Author:
kbecker (6/27/2011)
Parameters:
colName Name of column to change
dtype New 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: