Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ excel cell blank cells

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>

int main()
{
    std::fstream file("myfile.txt");
    std::vector<std::string> vec;

    if(file.is_open())
    {
        std::string line;
        bool Skip = true;

        while(std::getline(file, line))
        {
            std::stringstream sstr(line);
            std::string word;

            while (std::getline(sstr, word, ' '))
            {
                if(!word.empty())
                    vec.emplace_back(word);

                else if(word.empty() && Skip)
                {
                    vec.emplace_back("NaN");
                    Skip = false;
                }
            }
            Skip = true;
        }
        file.close();
    }

    for(size_t i = 0; i < vec.size(); ++i)
    {
        std::cout << vec[i] << " ";
        if((i+1)%3 ==0) std::cout << std::endl;
    }
    return 0;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #excel #cell #blank #cells
ADD COMMENT
Topic
Name
9+4 =