当前位置: 首页>>代码示例>>C++>>正文


C++ CSVRow::push_back方法代码示例

本文整理汇总了C++中CSVRow::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ CSVRow::push_back方法的具体用法?C++ CSVRow::push_back怎么用?C++ CSVRow::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSVRow的用法示例。


在下文中一共展示了CSVRow::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cr

void PivotCommand :: OutputPivot( IOManager & io ) {

    CSVRow r;
    r.push_back( "" );    // corresponds to row header
    for ( auto col : mCols ) {
        r.push_back( col );
    }
    io.WriteRow( r );

    for( auto row : mRows ) {
        r.clear();
        r.push_back( row );
        for ( auto col : mCols ) {
            ColRow cr( col, row );
            SumCount sc = mColRowValMap[ cr ];
            if ( mAction == Action::Average ) {
                r.push_back( ALib::Str( sc.mSum / sc.mCount ) );
            }
            else {
                r.push_back( ALib::Str( sc.mSum ) );
            }
        }
        io.WriteRow( r );
    }


}
开发者ID:bminossi,项目名称:csvfix,代码行数:27,代码来源:csved_pivot.cpp

示例2: if

void DSVReadCommand :: ParseDSV( const string & line, CSVRow & rv ) {

    CSVRow row;

    unsigned int pos = 0, len = line.size();
    string val;

    while( pos < len ) {
        char c = line[ pos++ ];
        if ( c == Delim() ) {
            while( mCollapseSep && ALib::Peek( line, pos ) == Delim() ) {
                pos++;
            }
            row.push_back( Unquote( val ) );
            val = "";
        }
        else if ( c == '\\' ) {
            if ( pos == len ) {
                CSVTHROW( "Escape at end of line" );
            }
            else {
                val += line[ pos++ ];
            }
        }
        else {
            val += c;
        }
    }

    row.push_back( Unquote( val )  );

    BuildCSVRow( row, rv );

}
开发者ID:purinda,项目名称:csvfix,代码行数:34,代码来源:csved_dsv.cpp

示例3: join

// Perform a join on two tables, using two provided strings representing the headers of the respective columns to join on
CSVTable CSVJoiner::join(CSVTable t1, CSVTable t2, std::string c1, std::string c2, Config &config) {
    CSVTable t3;
    CSVRow row;
    row.append( t1.rows[0].begin(), t1.rows[0].end() );
    row.append( t2.rows[0].begin(), t2.rows[0].end() );
    t3.push_back(row);

    int comp1 = t1.get_column_index(c1);
    int comp2 = t2.get_column_index(c2);

    // For left and right joins. Would be great if this was simply a vector of pointers.
    std::vector<CSVRow> remaining_rows1 = t1.rows;
    std::vector<CSVRow> remaining_rows2 = t2.rows;

    for (int i = 1; i < t1.rows.size(); i++) {
        for (int j = 1; j < t2.rows.size(); j++) {
            if( t1.rows[i][comp1] == t2.rows[j][comp2] ) {
                CSVRow row;
                row.append( t1.rows[i].begin(), t1.rows[i].end() );
                row.append( t2.rows[j].begin(), t2.rows[j].end() );
                t3.push_back(row);

                remaining_rows1[i].clear();
                remaining_rows2[j].clear();
            }
        }
    }

    if( config.join_left == true ) {
        for (int i = 1; i < remaining_rows1.size(); i++) {
            if( !remaining_rows1[i].empty() ) {
                CSVRow row = remaining_rows1[i];
                for (int j = 0; j < t2.column_count; j++) {
                    row.push_back("");
                }
                t3.push_back(row);
            }
        }
    }

    if( config.join_right == true ) {
        for (int i = 1; i < remaining_rows2.size(); i++) {
            if( !remaining_rows2[i].empty() ) {
                CSVRow row;
                for (int j = 0; j<t1.column_count; j++) {
                    row.push_back("");
                }
                row.append( remaining_rows2[i].begin(), remaining_rows2[i].end() );
                t3.push_back(row);
            }
        }
    }

    return t3;
}
开发者ID:pinetrees,项目名称:csv-reader,代码行数:56,代码来源:operators.cpp

示例4: MakeRow

void ReadFixedCommand :: MakeRow( const string & line, CSVRow & row ) {
	row.clear();
	unsigned int len = line.size();
	for( unsigned int i = 0; i < mFields.size(); i++ ) {
		if ( mFields[i].first > len ) {
			row.push_back( "" );
		}
		else {
			string val = line.substr( mFields[i].first - 1, mFields[i].second );
			row.push_back( mTrim ? ALib::RTrim( val ) : val );
		}
	}
}
开发者ID:darrennolan,项目名称:csvfix,代码行数:13,代码来源:csved_fixed.cpp

示例5:

void EvalCommand ::	Evaluate( CSVRow & row ) {

	bool skipelse = false;

	for ( unsigned int i = 0; i < mFieldExprs.size() ; i++ ) {
		if ( mIsIf[i] ) {
			if ( i < mFieldExprs.size() - 1  && mIsIf[i+2] ) {
				CSVTHROW( "Cannot have consecutive -if options" );
			}
			if ( i >= mFieldExprs.size() - 2 ) {
				CSVTHROW( "Need two -e options after -if" );
			}
			string r = mFieldExprs[i].mExpr.Evaluate();
			if ( ALib::Expression::ToBool( r ) ) {
				skipelse = true;
			} else {
				i++;
			}
			continue;
		}

		string r = mFieldExprs[i].mExpr.Evaluate();
		if ( mFieldExprs[i].mField < 0 || mFieldExprs[i].mField >= (int) row.size() ) {
			row.push_back( r );
		}
		else {
			row[ mFieldExprs[i].mField ] = r;
		}

		if ( skipelse ) {
			i++;
			skipelse = false;
		}
	}
}
开发者ID:bminossi,项目名称:csvfix,代码行数:35,代码来源:csved_eval.cpp

示例6: if

void JoinCommand :: WriteJoinRows( IOManager & io, const CSVRow & row ) {

	string key = MakeKey( row, true );

	MapType::const_iterator pos = mRowMap.lower_bound( key );
	MapType::const_iterator last = mRowMap.upper_bound( key );

	if ( mOuterJoin && pos == last ) {
		io.WriteRow( row );
	}
	else if ( mInvert ) {
		if ( pos == last ) {
			io.WriteRow( row );
		}
		return;
	}
	else {
		while( pos != last ) {
			const CSVRow & jr = pos->second;
			CSVRow newrow = row;
			for ( unsigned int i = 0; i < jr.size(); i++ ) {
				newrow.push_back( jr[i] );
			}
			io.WriteRow( newrow );
			++pos;
		}
	}
}
开发者ID:bminossi,项目名称:csvfix,代码行数:28,代码来源:csved_join.cpp

示例7: ns

void SummaryCommand :: DoMedian( IOManager & io ) {

	CSVRow r;

	for ( unsigned int i = 0; i < mFields.size(); i++ ) {
		unsigned int col = mFields[i];
		NumSort ns( col );
		std::sort( mRows.begin(), mRows.end(), ns );
		unsigned int sz = mRows.size();
		double d;
		if ( sz % 2 ) {
			unsigned int idx = (sz / 2);
			d = ALib::ToReal( mRows.at(idx).at(col) );
		}
		else {
			unsigned int idx = (sz / 2) - 1;
			double d1 = ALib::ToReal( mRows.at(idx).at(col) );
			double d2 = ALib::ToReal( mRows.at(idx+1).at(col) );
			d = (d1 + d2) /2;
		}

		r.push_back( ALib::Str( d ) );
	}

	io.WriteRow( r );
}
开发者ID:bminossi,项目名称:csvfix,代码行数:26,代码来源:csved_sum.cpp

示例8: DoAvg

void SummaryCommand :: DoAvg( IOManager & io ) {
	vector <double> sums;
	SumCols( sums );
	CSVRow r;
	for ( unsigned int i = 0; i < sums.size(); i++ ) {
		r.push_back( ALib::Str( sums.at(i) / mRows.size() ) );
	}
	io.WriteRow( r );
}
开发者ID:bminossi,项目名称:csvfix,代码行数:9,代码来源:csved_sum.cpp

示例9:

void DSVBase ::	BuildCSVRow( const CSVRow & in, CSVRow & out ) const {

    if ( mFields.size() == 0 ) {
        out = in;
    }
    else {
        out.clear();
        for ( unsigned int i = 0; i < mFields.size(); i++ ) {
            unsigned int f = mFields[ i ];
            if ( f < in.size() ) {
                out.push_back( in[ f ] );
            }
            else {
                out.push_back( "" );
            }
        }
    }
}
开发者ID:purinda,项目名称:csvfix,代码行数:18,代码来源:csved_dsv.cpp

示例10: ProcessRow

void PadCommand :: ProcessRow( CSVRow & row, unsigned int ncols,
									const ALib::CommaList & cl  ) {
	unsigned int sz = row.size();
	for ( unsigned int i = sz; i < ncols; i++ ) {
		if ( cl.Size() == 0 ) {
			row.push_back( "" );
		}
		else {
			unsigned int ci = i - sz;
			if ( ci >= cl.Size() ) {
				row.push_back( cl.At( cl.Size() - 1 ) );
			}
			else {
				row.push_back( cl.At( ci ) );
			}
		}
	}
}
开发者ID:bminossi,项目名称:csvfix,代码行数:18,代码来源:csved_truncpad.cpp

示例11: io

int FileInfoCommand :: Execute( ALib::CommandLine & cmd ) {

	GetSkipOptions( cmd );
	mTwoCols = cmd.HasFlag( FLAG_TWOC );
	mBasename = cmd.HasFlag( FLAG_BASEN );

	IOManager io( cmd );

	CSVRow row;
	while( io.ReadCSV( row ) ) {
		if ( Skip( io, row ) ) {
			continue;
		}
		if ( Pass( io, row ) ) {
			io.WriteRow( row );
			continue;
		}

		string fname = mBasename
						? ALib::Filename( io.CurrentFileName() ).Base()
						: io.CurrentFileName();

		CSVRow outrow;
		if ( mTwoCols ) {
			outrow.push_back( fname );
			outrow.push_back( ALib::Str( io.CurrentLine() ));
		}
		else {
			outrow.push_back( fname + " ("
				+ ALib::Str( io.CurrentLine() ) + ")"
			);
		}
		ALib::operator+=( outrow, row );
		io.WriteRow( outrow );
	}

	return 0;
}
开发者ID:bminossi,项目名称:csvfix,代码行数:38,代码来源:csved_fileinfo.cpp

示例12: ProcessFlags

void AsciiTableCommand :: ProcessFlags( ALib::CommandLine & cmd ) {
	mUseLineSep = cmd.HasFlag( FLAG_SEP );
	mHeadings = ALib::CommaList( cmd.GetValue( FLAG_HEADER, "" ) );
	ALib::CommaList ra = ALib::CommaList( cmd.GetValue( FLAG_RALIGN, "" ) );
	CommaListToIndex( ra, mRightAlign );

	if ( mHeadings.Size() && mHeadings.At(0) != FILE_HEADER) {
		CSVRow r;
		for ( unsigned int i = 0; i < mHeadings.Size() ; i++ ) {
			r.push_back( mHeadings.At( i ) );
		}
		AddRow( r );
	}
}
开发者ID:darrennolan,项目名称:csvfix,代码行数:14,代码来源:csved_atable.cpp

示例13: WriteRow

void  ReadXMLCommand :: WriteRow( const ALib::XMLElement * r,
										IOManager & io ) {
	CSVRow row;

	for ( unsigned int i = 0; i < r->ChildCount(); i++  ) {
		const ALib::XMLElement * ce = r->ChildElement( i );
		if ( ce && ce->Name() == "td" ) {
			row.push_back( TDToCSV( ce ) );
		}
	}

//	ALib::Dump( std::cout, row );
	io.WriteRow( row );
}
开发者ID:bminossi,项目名称:csvfix,代码行数:14,代码来源:csved_xml.cpp

示例14: BuildRowMap

void JoinCommand :: BuildRowMap( ALib::CSVStreamParser * sp ) {
	string line;
	std::unique_ptr <ALib::CSVStreamParser> p( sp );
	CSVRow row;
	while( p->ParseNext( row ) ) {
		string key = MakeKey( row, false );
		CSVRow jrow;
		for ( unsigned int i = 0; i < row.size(); i++ ) {
			if ( (! IsJoinCol( i )) || mKeep  ) {
				jrow.push_back( row[i] );
			}
		}
		mRowMap.insert( std::make_pair( key, jrow ) );
	}
}
开发者ID:bminossi,项目名称:csvfix,代码行数:15,代码来源:csved_join.cpp

示例15: readCSV

void AbstractFileSource::readCSV(std::ifstream &input, CSVDatabase &db) {
	String csvLine;
	// read every line from the stream
	while( std::getline(input, csvLine) ){
		std::istringstream csvStream(csvLine);
		CSVRow csvRow;
		String csvCol;
		// read every element from the line that is seperated by commas
		// and put it into the vector or strings
		while( std::getline(csvStream, csvCol, ','))
			csvRow.push_back(csvCol);
		db.push_back(csvRow);
	}

};
开发者ID:haoyuli,项目名称:DymonRepo,代码行数:15,代码来源:AbstractFileSource.cpp


注:本文中的CSVRow::push_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。