var source = new CustomSource ();
Console . WriteLine ( $"Data in input file:" );
Console . WriteLine ( File . ReadAllText ( "res/examples/InputData.csv" ));
StreamReader stream = null ;
source . OnInitialization = () => {
stream = new StreamReader ( "res/examples/InputData.csv" );
};
source . ReadFunc = _ => {
var line = stream . ReadLine ();
var data = line . Split ( ',' );
dynamic result = new ExpandoObject ();
result . Id = data [ 0 ];
result . Value = data [ 1 ] + data [ 2 ];
return result ;
};
source . ReadingCompleted = _ => stream . EndOfStream ;
var dest = new MemoryDestination ();
source . LinkTo ( dest );
Network . Execute ( source );
Console . WriteLine ( "" );
Console . WriteLine ( $"Data processed by ETL pipeline:" );
foreach ( dynamic row in dest . Data )
Console . WriteLine ( $"Id: {row.Id} Value: {row.Value}" );
//Output
/*
Data in input file:
Id,Value1,Value2
1,Test1,A
2,Test2,B
3,Test3,C
4,Test4,D
Data processed by ETL pipeline:
Id: Id Value: Value1Value2
Id: 1 Value: Test1A
Id: 2 Value: Test2B
Id: 3 Value: Test3C
Id: 4 Value: Test4D
*/