using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using LumenWorks.Framework.IO.Csv; namespace PermitSample { // // Class to read the input data without presuming where that data comes from; it could be a csv file, // a database, or something else. The code for this class should be replaced by code to read the data from your source. // // The code for this instance of this class is a wrapper for the LumenWorks csv reader. // class DataReader { private CsvReader _csv; public DataReader() { /// force StreamReader to open file readonly, with sharing allowed - by default file is locked, so if you /// have it open in another filereader or with excel it won't be able to process the csv FileStream fs = new FileStream(@"\\digmap.local\Users\jwilson\My Documents\PermitSampleSJC.csv", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); _csv = new CsvReader(new StreamReader(fs), true); _csv.DefaultParseErrorAction = ParseErrorAction.AdvanceToNextLine; } public bool ReadNext() { return _csv.ReadNextRecord(); } public string GetField(string FieldName) { return _csv[FieldName]; } public string this[string FieldName] { get { return _csv[FieldName]; } } } }