Exemplo n.º 1
0
void UploadImpl::importButton()
{
    QString file;
    file = QFileDialog::getOpenFileName(this,
                                        tr("Import Exercise Data"),
                                        "",
                                        tr("Comma separated files (*.csv *.txt);;Garmin FIT file (*.fit)"));
    
    if (!file.isEmpty())
    {
	if ( QFileInfo(file.toLower()).suffix() == "fit") {
	  // Garmin FIT file
            QFile fitFile(file);
            if (!fitFile.open(QIODevice::ReadOnly)) return;
            QByteArray blob = fitFile.readAll();            
            std::vector<uint8_t> fitData(blob.begin(), blob.end());
           
            FIT fit;
            fit.parse (fitData, exdata);
	  
	} else {
	  // csv file
	  ReadCSV(qPrintable(file), exdata);
	}
        if (exdata.size())
          {
              fillList();
          }

    }
}
Exemplo n.º 2
0
std::vector<vector3f> ReadVector3CSV( const char *file, char sep )
{
	auto data=ReadCSV(file ,sep);

	std::vector<vector3f> r(data.size());

	for (int i=0;i<data.size();i++){
		r[i]=vector3f(data[i][0],data[i][1],data[i][2]);
	}
	return r;
}
SSentenceSource::SSentenceSource(std::string path) {
    std::ifstream in(path, std::ios::in | std::ios::binary);
    std::vector<std::vector<std::string>> contents;
    std::vector<std::vector<std::string>>::iterator it;
    // Double-check the file opened
    if (!in) throw(errno);
    // Read the file
    ReadCSV(in, contents);
    // Iterate over the contents
    it = contents.begin();
    // "Topic","Sentiment","TweetId","TweetDate","TweetText"
    while (it != contents.end()) {
        it++; // Skip header row 
        if (it == contents.end()) break;
        Sentence            *s;
        ClassificationLabel label;
        auto fields = *it;
        if (fields.size() < 5) continue;
        // Recognize the label
        std::string slabel = fields[1];
        if (slabel == "irrelevant") continue;
        if (slabel == "positive") {
            label = PositiveSentenceLabel;
        }
        else if (slabel == "negative") {
            label = NegativeSentenceLabel;
        }
        else {
            continue;
        }
        // Create the sentence
        std::transform(fields[4].begin(), fields[4].end(), fields[4].begin(), ::tolower);
        s = new Sentence(label, fields[4].c_str());
        this->sentences.push_back(s);
    }
}