hosseinmoein / DataFrame

C++ DataFrame for statistical, Financial, and ML analysis -- in modern C++ using native types and contiguous memory storage
https://hosseinmoein.github.io/DataFrame/
BSD 3-Clause "New" or "Revised" License
2.54k stars 313 forks source link

catch an error when read csv file : Index column is not the first column #195

Closed xkungfu closed 2 years ago

xkungfu commented 2 years ago

the first line content of the file is : INDEX:0:<ulong>,id:0:<double>,ticker:0:<string>,name:0:<string>,close_price:0:<double>,change_percentage:0:<double>,change_amount:0:<double>,turnover_vol:0:<double>,turnover_amount:0:<double>,amplitude:0:<double>,highest_price:0:<double>,lowest_price:0:<double>,open_price:0:<double>,last_close:0:<double>,turnover_vol_ratio:0:<double>,turnover_rate:0:<double>,ma5:0:<double>,ma10:0:<double>,ma20:0:<double>,ma30:0:<double>,ma60:0:<double>,trade_date:0:<string>,nonrest_float_amount:0:<double> the code is :


        ULDataFrame cachedf;
        try  {
            cachedf.read("I:\\temp\\test.csv", io_format::csv2);
        }
        catch (const DataFrameError &ex)  {
            std::cout << "DataFrameError error: " << ex.what() << std::endl;
        }

the file is saved by python pandas. python code is:

all_df.to_csv("I:\\temp\\test.csv", encoding="utf-8-sig")

please help to find where is the error in the codes?

thanks!

xkungfu commented 2 years ago

change "utf-8-sig" to "utf-8" resolved this issue.