Search code examples
c++csvc++17multi-index

C++ multiindex column csv load


Multi-index column csv is enter image description here

  1. Its size is (8, 8415).
  2. This csv file was made from pandas multi-index dataframe (python).
  3. Its columns are [codes X financial items].

codes are enter image description here

financial items are enter image description here

How can I use this csv file to use its year(2014, 2015, ....) as index and codesXfinancial items as multi columns?


Solution

  • What kind of output you want is unclear. There are not many libraries to imitate pandas in C++. A very messy, convoluted and inelegant way of doing it is declaring a structure and then put it into a list. Something like,

    struct dataframe{
        double data;
        int year;
        int code;
        char item[];   //or you can use "string item;"
    }
    

    Make a list of this structure either by a custom class or C++ native "list" class. If you can provide a more detailed explanation of what kind of data structure you want in the program or what do you want to do with it, I would try to provide a better solution.