Esempio n. 1
0
void TruncCommand :: ProcessRow( CSVRow & row, unsigned int ncols,
									const ALib::CommaList &  ) {
	if ( ncols < row.size() ) {
		CSVRow nrow( ncols );
		std::copy( row.begin(), row.begin() + ncols, nrow.begin() );
		row.swap( nrow );
	}
}
Esempio n. 2
0
void AbstractFileSource::display(const CSVRow& row) {
	if(!row.size())
		return;
	CSVRowCI i=row.begin();
	std::cout<<*(i++);
	for(;i != row.end();++i)
		std::cout<<','<<*i;
};
Esempio n. 3
0
void SummaryCommand :: DoFreq( IOManager & io ) {
	CalcFreqs();

	for ( unsigned int i = 0; i < mRows.size(); i++ ) {
		string key = MakeKey( mRows.at(i) );
		unsigned int n = mFreqMap.find( key )->second.mFreq;
		CSVRow r = mRows.at(i);
		r.insert( r.begin(), ALib::Str( n ) );
		io.WriteRow( r );
	}
}
Esempio n. 4
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 );
}
Esempio n. 5
0
void SummaryCommand :: DoMode( IOManager & io ) {

	unsigned int mode = CalcFreqs();

	for ( FreqMap::const_iterator it = mFreqMap.begin();
			it != mFreqMap.end(); ++it ) {

		if ( it->second.mFreq == mode ) {
			for ( unsigned int i = 0; i < it->second.mIndex.size(); i++ ) {
				CSVRow r = mRows.at( it->second.mIndex.at(i) );
				r.insert( r.begin(), ALib::Str( mode ) );
				io.WriteRow( r );
			}
		}
	}
}
Esempio n. 6
0
void CSVFormatter::formatRow(const CSVRow& row, UnicodeString& result, UChar32 sepchar, unsigned int varformat) {
	result.remove();
	UnicodeString formatted;
	int lastcolumn=0;
	CSVRecordMap::const_iterator iter;
	for (iter=row.begin(); iter!=row.end(); ++iter) {
		for (; lastcolumn<iter->first; ++lastcolumn) {
			result.append(sepchar);
		}
		if (iter->second) {
			iter->second->getValueFormatted(formatted, varformat);
		//	result.append(iter->second->getTypeName());
		//	result.append(':');
			result.append(formatted);
		//} else {
		//	result.append("[null]");
		}
	}
}