Skip to content

QuickManifoldLoad

Cinchoo edited this page Dec 11, 2017 · 1 revision

Loading Manifold (Multi record) file

To load manifold file, use ChoManifoldReader component to parse it. Sample below shows how to load file (sample.txt) containing delimited as well as fixed length data. In order to process this file successfully, you need to determine the identifier or logic to determine the type of record. In this sample, I'm going to specify any line with length of 90 will be fixed length record.

1,"Eldon Base for stackable storage shelf, platinum",Muhammed MacIntyre,3,-213.25,38.94,35,Nunavut,Storage & Organization,0.8
2,"1.7 Cubic Foot Compact ""Cube"" Office Refrigerators",Barry French,293,457.81,208.16,68.02,Nunavut,Appliances,0.58
3,"Cardinal Slant-D® Ring Binder, Heavy Gauge Vinyl",Barry French,293,46.71,8.69,2.99,Nunavut,Binders and Binder Accessories,0.39
101     Reeves          Keanu           9315.45     10000.00      1/17/1998       A      
312     Butler          Gerard          90.00       1000.00       8/6/2003        B      
868     Hewitt          Jennifer Love   0           17000.00      5/25/1985       B      
761     Pinkett-Smith   Jada            49654.87    100000.00     12/5/2006       A      
317     Murray          Bill            789.65      5000.00       2/5/2007        C      

Load using iterator

using (var r = new ChoKVPManifoldReader(@"sample.txt")
                .WithCustomRecordSelector((l) =>
                {
                    if (l.Length == 90)
                        return typeof(FixedLengthEmp);
                    else
                        return typeof(CSVEmp);
                })
)
{
	foreach (var item in r)
	{
		Console.WriteLine(item.ToString());
	}
}

Load using loop

using (var r = new ChoManifoldReader(@"sample.txt")
                .WithCustomRecordSelector((l) =>
                {
                    if (l.Length == 90)
                        return typeof(FixedLengthEmp);
                    else
                        return typeof(CSVEmp);
                })
)
{
	object rec;
	while ((rec = r.Read()) != null)
	{
		Console.WriteLine(rec.ToString());
	}
}