Sample Flat File
Sample flat file is available at:
Sample Flat File Template
Sample flat-file template is available at:
EDI Tools for .NET C# Examples
The example below is part of the EDI Tools for .NET C# Code Examples.
The Parse Custom Flat File code is also available on GitHub
Additional operations for Flat Files
How to parse custom Flat File with EDI Tools for .NET
using EdiFabric.Framework.Readers; using System.Diagnostics; using System.IO; using System.Reflection; using System.Text; using EdiFabric.Core.Model.Edi; using System.Collections.Generic; using EdiFabric.Framework; namespace EdiFabric.Examples.FlatFile.Read { class ReadCSVFile { public static void Run() { Debug.WriteLine("******************************"); Debug.WriteLine(MethodBase.GetCurrentMethod().Name); Debug.WriteLine("******************************"); Stream ediStream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files\Flat_PO.txt"); List<IEdiItem> items = new List<IEdiItem>(); using (StreamReader streamReader = new StreamReader(ediStream, Encoding.UTF8, true, 1024)) { using (var flatReader = new FlatReader(streamReader, FlatFactory)) { while (flatReader.Read()) { items.Add(flatReader.Item); } } } } private static MessageContext FlatFactory(string segment) { var id = segment.Substring(0, 2); switch (id) { case "PO": return new MessageContext("PO", "Flat", mc => Assembly.Load(new AssemblyName("EdiFabric.Examples.FlatFile.Common"))); case "H,": return new MessageContext("Markers", "Flat", mc => Assembly.Load(new AssemblyName("EdiFabric.Examples.FlatFile.Common"))); } return null; } } }
Comments
0 comments
Please sign in to leave a comment.