Example #1
0
void AddVars( ALib::Expression & e, const IOManager & io, const CSVRow & row ) {
	e.ClearPosParams();
	e.AddVar( LINE_VAR, ALib::Str( io.CurrentLine() ));
	e.AddVar( FILE_VAR, ALib::Str( io.CurrentFileName()));
	e.AddVar( FIELD_VAR, ALib::Str( row.size()));
	for ( unsigned int j = 0; j < row.size(); j++ ) {
		e.AddPosParam( row.at( j ) );
	}
}
Example #2
0
void TrimCommand :: Chop( CSVRow & row, unsigned int  i ) {
    if ( mFields.size() == 0 ) {
        if ( i < mWidths.size()  && i < row.size() ) {
            if ( mWidths.at(i) >= 0 ) {
                row.at(i) = row.at(i).substr( 0, mWidths.at(i) );
            }
        }
    }
    else {
        int idx =  ALib::IndexOf( mFields, i );
        if ( idx >= 0 ) {
            if ( idx < (int) mWidths.size()  && i < row.size() ) {
                if ( mWidths.at(idx) >= 0 ) {
                    row.at(i) = row.at(i).substr( 0, mWidths.at(idx) );
                }
            }
        }
    }
}
Example #3
0
static void SumRow( vector <double> & sums, const CSVRow & row,
						const FieldList & fl ) {

	for ( unsigned int i = 0; i < fl.size(); i++ ) {
		unsigned int fi = fl.at(i);
		if ( fi >= row.size() ) {
			CSVTHROW( "Invalid field index" );
		}
		sums.at(i) += ALib::ToReal( row.at(fi) );
	}
}
Example #4
0
string SummaryCommand :: MakeKey( const CSVRow & row ) const {
	string key;
	for ( unsigned int i = 0; i < mFields.size(); i++ ) {
		if ( mFields.at(i) >= row.size() ) {
			key += "";
		}
		else {
			key += row.at( mFields.at(i) );
		}
		key += '\0';
	}
	return key;
}
Example #5
0
void ExcludeCommand :: Exclude(  CSVRow & r ) const {

	CSVRow out;

	if ( mReverse ) {
		std::reverse( r.begin(), r.end() );
	}

	for ( unsigned int i = 0; i < r.size(); i++ ) {
		if ( ! ALib::Contains( mFields, i ) ) {
			out.push_back( r.at( i ) );
		}
	}

	if ( mReverse ) {
		std::reverse( out.begin(), out.end() );
	}

	r.swap( out );
}