Esempio n. 1
0
        public static void ParseFixedWidthString(StringReader sourceReader, Action <string[], long> dataReadAction, int[] fieldWidths, bool trimWhiteSpace = true)
        {
            string data = sourceReader.ReadLine();
            FixedWidthLineParser lineParser = new FixedWidthLineParser(fieldWidths, trimWhiteSpace: trimWhiteSpace);

            dataReadAction(lineParser.Parse(data), 1);
        }
Esempio n. 2
0
        private static void ParseFixedWidth(string sourceFileName, int[] fieldWidths, bool trimWhiteSpace, Action <string[], long> dataReadAction)
        {
            using (StreamReader sr = new StreamReader(sourceFileName))
            {
                long lineNum = 0;

                FixedWidthLineParser lineParser = new FixedWidthLineParser(fieldWidths, trimWhiteSpace: trimWhiteSpace);

                foreach (string line in LineGenerator(sr))
                {
                    lineNum++;

                    string[] values = lineParser.Parse(line);

                    dataReadAction(values, lineNum);
                }
            }
        }