Example #1
0
        private List <List <String> > parseRows(String source, Action <CsvStreamToRowProcessor> callback = null)
        {
            StreamInformation       si         = new StreamInformation(new Settings());
            CsvStreamToRowProcessor csvProcess = new CsvStreamToRowProcessor();

            StringStreamFactory wrapper = new StringStreamFactory(source);

            csvProcess.setSource(si, wrapper);

            CaptureRowProcessor capture = new CaptureRowProcessor();

            csvProcess.setNextRowProcessor(capture);

            if (callback != null)
            {
                callback(csvProcess);
            }

            try
            {
                csvProcess.process();
                return(capture.rows);
            }
            finally
            {
                try { wrapper.Dispose(); } catch (Exception) { }
                try { csvProcess.Dispose(); } catch (Exception) { }
            }
        }
Example #2
0
        public IProcessor buildProcessor(StreamInformation streamInformation, IStreamFactory streamFactory)
        {
            CsvStreamToRowProcessor result = new CsvStreamToRowProcessor(settings);

            result.hasHeader = hasHeader;
            result.setSource(streamInformation, streamFactory);
            return(result);
        }