Isis 3.0 Developer's Reference (API) |
Home |
Import a PDS table file with a label description. More...
#include <ImportPdsTable.h>
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. |
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.
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.
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.
labfile | Name of table label file | |
tabfile | Name of table data file |
References load().
Isis::ImportPdsTable::~ImportPdsTable | ( | ) | [inline] |
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.
colNames | Vector column names to convert to a table. | |
tname | Name of the table to create. |
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.
colNames | String containing comma delimited column names to export | |
tname | Name of table to create |
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.
tname | Name of table |
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.
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. |
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.
formatted | Specifies to convert the name to Camel-Case if true, otherwise leave as is in the PDS table. |
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.
colName | Name of column to get type for |
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.
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.
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. |