xtensor icon indicating copy to clipboard operation
xtensor copied to clipboard

error C2440: “static_cast” can't convert from “const A1” to “R”

Open xkungfu opened this issue 2 years ago • 2 comments

my csv file column fields: date, username, vol, type all fields are string fromat. Error occurred when convert string to int:

C++ code:

auto data = xt::load_csv<string>(csvfile);
auto col2 = xt::col(data, 2)
auto vol = xt::cast<int>(col2);

ERROR: error C2440: “static_cast” can't convert from “const A1” to “R”

xkungfu avatar Aug 03 '21 14:08 xkungfu

That seems reasonable because I think that there is no cast from std::string to int. You have to use std::stoi (see https://stackoverflow.com/a/7664227/2646505 ). I don't know if we have an equivalent in xtensor. If not I would be open to having one.

tdegeus avatar Aug 05 '21 07:08 tdegeus

that is : if I load data from a csv file, all values in it must be number? as you know, all financial data have a column date, and ticker, and security name, how to load a financial csv file to int or double? how others use xtensor to handle these files?

xkungfu avatar Aug 05 '21 12:08 xkungfu