Skip to content

Instantly share code, notes, and snippets.

@minisu
Created February 19, 2013 15:58
Show Gist options
  • Save minisu/4987148 to your computer and use it in GitHub Desktop.
Save minisu/4987148 to your computer and use it in GitHub Desktop.
/**
* @id com.eviware.DataSource
* @category flow
* @dependency com.xlson.groovycsv:groovycsv:1.0
*/
import com.xlson.groovycsv.CsvParser
createOutgoing( 'output' )
csvIterator = null
def csv = '''Name,Lastname
Mark,Andersson
Pete,Hansen'''
createProperty('inputFile', File ) {
csvIterator = new CsvParser().parseCsv( csv )
}
onMessage = { outgoing, incoming, message ->
if( csvIterator.hasNext() )
{
propertyMapper = csvIterator.next()
for( c in propertyMapper.columns )
{
println( propertyMapper.values[ c.value ] )
message << [ (c.key) : propertyMapper.values[ c.value ] ]
}
}
send( output, message )
}
onAction( 'RESET' ) {
csvIterator = new CsvParser().parseCsv( csv )
}
layout {
property( property:inputFile, constraints: 'w 200!', label:'Input file' )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment