diff --git a/lib/algorithms/kde.h b/lib/algorithms/kde.h index a60b40b..6ba1424 100644 --- a/lib/algorithms/kde.h +++ b/lib/algorithms/kde.h @@ -30,7 +30,6 @@ #include "../core.h" #include "../maths.h" -#include "../io.h" namespace gctl { diff --git a/lib/io/dsv_io.cpp b/lib/io/dsv_io.cpp index 335c6c0..a9687ee 100644 --- a/lib/io/dsv_io.cpp +++ b/lib/io/dsv_io.cpp @@ -538,7 +538,7 @@ int gctl::dsv_io::name_index(std::string name, bool iter_row) { int r = atoi(std::string(ret[1]).c_str()); if (r >= 1 && r <= row_num_) return r; - else return -1; + else return -2; } return -1; @@ -554,7 +554,7 @@ int gctl::dsv_io::name_index(std::string name, bool iter_row) { int c = atoi(std::string(ret[1]).c_str()); if (c >= 1 && c <= col_num_) return c; - else return -1; + else return -2; } return -1; @@ -745,7 +745,15 @@ void gctl::dsv_io::filter(linebool_func_t func, table_headtype_e thead) void gctl::dsv_io::cal_column(std::string expr_str, const std::vector &col_list, int p) { array idx(col_list.size()); - for (size_t i = 0; i < col_list.size(); i++) + idx[0] = name_index(col_list[0]); + if (idx[0] < 0) + { + if (idx[0] == -1) add_column(col_list[0]); + else add_column(); + column_type(Float, col_list[0]); + } + + for (size_t i = 1; i < col_list.size(); i++) { idx[i] = name_index(col_list[i]); diff --git a/lib/io/dsv_io.h b/lib/io/dsv_io.h index 50f7e80..cd3fc7b 100644 --- a/lib/io/dsv_io.h +++ b/lib/io/dsv_io.h @@ -441,8 +441,8 @@ namespace gctl * @brief 返回名称为name和R和C的行或列的索引 * * @param name 名称 可以是具体的名称(如有),或者是R和C - * @param iter_row 搜索行名称(默认为搜索列名称),如果name参数为R和C则此参数无效 - * @return 索引 返回的索引(大于等于1 小于等于行数或列数)失败则返回-1 + * @param iter_row 搜索行名称(默认为搜索列名称) + * @return 索引 返回的索引(大于等于1 小于等于行数或列数)失败则返回-1表示匹配失败-2表示匹配成功但超过有效范围 */ int name_index(std::string name, bool iter_row = false);