This commit is contained in:
张壹 2025-05-08 14:20:30 +08:00
parent 8ae228a0d3
commit 541ef075f2
4 changed files with 33 additions and 1 deletions

View File

@ -26,7 +26,7 @@ add_example(kde_ex OFF)
add_example(meshio_ex OFF)
add_example(autodiff_ex OFF)
add_example(multinary_ex OFF)
add_example(text_io_ex OFF)
add_example(dsv_io_ex OFF)
add_example(getoption_ex OFF)
add_example(process_ex OFF)
add_example(array_ex OFF)

View File

@ -42,6 +42,8 @@ int main(int argc, char const *argv[]) try
//tc.filter("America", "BLZ", RowHead);
//tc.save_text("out");
if (tc.has_column("Continent_s")) std::cout << "Find Column\n";
dsv_io tc2 = tc.export_table();
//tc2.head_records(tc.head_records());
tc2.delimeter('|');

View File

@ -643,6 +643,12 @@ void gctl::dsv_io::row_output(std::string name, switch_type_e s)
return;
}
bool gctl::dsv_io::has_column(std::string name)
{
if (name_index(name) != -1) return true;
return false;
}
int gctl::dsv_io::add_column(std::string name, int idx)
{
if (idx <= 0) throw std::runtime_error("[gctl::dsv_io] Invalid column index.");
@ -678,6 +684,12 @@ int gctl::dsv_io::add_column(std::string name, std::string id_name)
return add_column(name, name_index(id_name));
}
bool gctl::dsv_io::has_row(std::string name)
{
if (name_index(name, true) != -1) return true;
return false;
}
int gctl::dsv_io::add_row(std::string name, int idx)
{
if (idx <= 0) throw std::runtime_error("[gctl::dsv_io] Invalid row index.");

View File

@ -491,6 +491,15 @@ namespace gctl
*/
void row_output(std::string name, switch_type_e s = Disable);
/**
* @brief
*
* @param name
* @return true
* @return false
*/
bool has_column(std::string name);
/**
* @brief idx的位置插入一个空白列idx大于列数则在表尾添加一列
*
@ -511,6 +520,15 @@ namespace gctl
*/
int add_column(std::string name, std::string id_name);
/**
* @brief
*
* @param name
* @return true
* @return false
*/
bool has_row(std::string name);
/**
* @brief idx的位置插入一个空白行idx大于等于行数则在表尾添加一行
*