40#include <libdap/DAS.h>
41#include <libdap/Error.h>
45#include <BESNotFoundError.h>
50void csv_read_attributes(DAS &das,
const string &filename)
52 unique_ptr<CSV_Obj> csvObj(
new CSV_Obj);
54 if (!csvObj->open(filename)) {
55 throw BESNotFoundError(
string(
"Unable to open file ").append(filename), __FILE__, __LINE__);
60 BESDEBUG(
"csv",
"File Loaded:" << endl << *csvObj << endl );
62 vector<string> fieldList;
63 csvObj->getFieldList(fieldList);
65 for (
const auto &field: fieldList) {
66 AttrTable *attr_table_ptr = das.get_table(field.c_str());
68 if (!attr_table_ptr) attr_table_ptr = das.add_table(field,
new AttrTable);
71 string type = csvObj->getFieldType(field);
72 attr_table_ptr->append_attr(
"type",
"String", type);
error thrown if the resource requested cannot be found