Created
February 19, 2013 15:58
-
-
Save minisu/4987148 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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