Isis Developer Reference
LoadCSV.h
Go to the documentation of this file.
1 #ifndef LoadCSV_h
2 #define LoadCSV_h
3 
10 /* SPDX-License-Identifier: CC0-1.0 */
11 
12 #include <cmath>
13 #include <string>
14 #include <vector>
15 
16 #include "IString.h"
17 #include "HiCalTypes.h"
18 #include "HiCalUtil.h"
19 #include "HiCalConf.h"
20 #include "CSVReader.h"
21 
22 namespace Isis {
23 
24  class iException;
25 
52  class LoadCSV {
53 
54  public:
55  // Constructors and Destructor
56  LoadCSV();
57  LoadCSV(const QString &base, const HiCalConf &conf,
58  const DbProfile &profile);
59 
61  virtual ~LoadCSV() { }
62 
63  void load(const QString &base, const HiCalConf &conf,
64  const DbProfile &profile);
65 
66  QString filename() const;
67  int size() const;
68 
69  bool validateSize(const int &expected,
70  const bool &throw_on_error = false)
71  const;
72 
73  HiVector getVector() const;
74  HiMatrix getMatrix() const;
75 
76  void History(HiHistory &history) const;
77 
78  private:
79  QString _base;
80  DbProfile _csvSpecs;
81  HiMatrix _data;
82  std::vector<QString> _history;
83 
84  void init(const QString &base, const HiCalConf &conf,
85  const DbProfile &profile);
86  void addHistory(const QString &element, const QString &desc);
87  void getKeyList(const QString &base, std::vector<QString> &keys)
88  const;
89  DbProfile ResolveKeys(const QString &base, const HiCalConf &conf,
90  const DbProfile &prof) const;
91  QString ParsedKey(const QString &key, const HiCalConf &conf,
92  const DbProfile &prof) const;
93  QString makeKey(const QString &ksuffix = "") const;
94  QString getValue(const QString &ksuffix = "") const;
95  HiMatrix extract (const CSVReader &csv);
96  int getAxisIndex(const QString &name,
97  const CSVReader::CSVAxis &header) const;
98 
99  };
100 
101 } // namespace Isis
102 #endif
Isis::IsEqual
bool IsEqual(const QString &v1, const QString &v2="TRUE")
Shortened string equality test.
Definition: HiCalUtil.h:258
Isis::CSVReader::getColumn
CSVAxis getColumn(int index) const
Parse and return a column specified by index order.
Definition: CSVReader.cpp:218
Isis::CSVReader::CSVAxis
Parser::TokenList CSVAxis
Row/Column token list.
Definition: CSVReader.h:247
FileName.h
Isis::CSVReader::columns
int columns() const
Determine the number of columns in the input source.
Definition: CSVReader.cpp:97
Isis::CSVReader::setComment
void setComment(const bool ignore=true)
Allows the user to indicate comment disposition.
Definition: CSVReader.h:313
Isis::CSVReader
Reads strings and parses them into tokens separated by a delimiter character.
Definition: CSVReader.h:239
Isis::ToString
QString ToString(const T &value)
Helper function to convert values to strings.
Definition: HiCalUtil.h:246
Isis::CSVReader::getRow
CSVAxis getRow(int index) const
Parse and return the requested row by index.
Definition: CSVReader.cpp:188
Isis::DbProfile::exists
bool exists(const QString &key) const
Checks for the existance of a keyword.
Definition: DbProfile.h:115
Isis::CSVReader::setHeader
void setHeader(const bool gotIt=true)
Allows the user to indicate header disposition.
Definition: CSVReader.h:383
Isis::HiMatrix
TNT::Array2D< double > HiMatrix
2-D buffer
Definition: HiCalTypes.h:28
CSVReader.h
Isis::ConfKey
T ConfKey(const DbProfile &conf, const QString &keyname, const T &defval, int index=0)
Find a keyword in a profile using default for non-existant keywords.
Definition: HiCalUtil.h:205
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::LoadCSV::load
void load(const QString &base, const HiCalConf &conf, const DbProfile &profile)
Definition: LoadCSV.cpp:32
Isis::LoadCSV::getVector
HiVector getVector() const
Definition: LoadCSV.cpp:196
Isis::CSVReader::setDelimiter
void setDelimiter(const char &delimiter)
Set the delimiter character that separate tokens in the strings.
Definition: CSVReader.h:400
Isis::LoadCSV::History
void History(HiHistory &history) const
Definition: LoadCSV.cpp:206
LoadCSV.h
Isis::CSVReader::setSkipEmptyParts
void setSkipEmptyParts()
Indicate multiple occurances of delimiters are one token.
Definition: CSVReader.h:435
HiCalConf.h
Isis::LoadCSV::~LoadCSV
virtual ~LoadCSV()
Destructor.
Definition: LoadCSV.h:61
Isis::CSVReader::getHeader
CSVAxis getHeader() const
Retrieve the header from the input source if it exists.
Definition: CSVReader.cpp:168
Isis::LoadCSV::filename
QString filename() const
Definition: LoadCSV.cpp:176
Isis::HiHistory
Definition: HiCalTypes.h:30
Isis::LoadCSV
Provides generalized access to HiRISE calibration CSV files.
Definition: LoadCSV.h:52
IString.h
Isis::LoadCSV::size
int size() const
Definition: LoadCSV.cpp:180
Isis::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
Isis::LoadCSV::getMatrix
HiMatrix getMatrix() const
Definition: LoadCSV.cpp:201
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::toInt
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:93
Isis::ToInteger
int ToInteger(const T &value)
Helper function to convert values to Integers.
Definition: HiCalUtil.h:222
HiCalUtil.h
Isis::LoadCSV::LoadCSV
LoadCSV()
Definition: LoadCSV.cpp:24
Isis::DbProfile
A DbProfile is a container for access parameters to a database.
Definition: DbProfile.h:51
HiCalTypes.h
Isis::HiVector
TNT::Array1D< double > HiVector
1-D Buffer
Definition: HiCalTypes.h:27
Isis::CSVReader::read
void read(const QString &fname)
Reads the entire contents of a file for subsequent parsing.
Definition: CSVReader.cpp:140
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::HiHistory::add
void add(const QString &event)
Definition: HiCalTypes.h:55
Isis::Null
const double Null
Value for an Isis Null pixel.
Definition: SpecialPixel.h:95
Isis::ToDouble
double ToDouble(const T &value)
Helper function to convert values to doubles.
Definition: HiCalUtil.h:234
IException.h
std
Namespace for the standard library.
Isis::CSVReader::setSkip
void setSkip(int nskip)
Indicate the number of lines at the top of the source to skip to data.
Definition: CSVReader.h:335
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::CSVReader::rows
int rows() const
Reports the number of rows in the table.
Definition: CSVReader.h:285
Isis::LoadCSV::validateSize
bool validateSize(const int &expected, const bool &throw_on_error=false) const
Definition: LoadCSV.cpp:184
Isis::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126