Beispiel #1
0
        /// <summary>
        /// Reads a line from the instance CSV
        /// </summary>
        /// <returns>The fields in a List, ordered left-to-right in the order parsed, or null if: a) there is no more data, or
        /// b) the EOF string was encountered, or c) MaxRows were read
        /// </returns>
        public override List <string> ReadLine()
        {
            string        InputLine;
            List <string> Fields = null;

            while ((InputLine = NextLine()) != null)
            {
                ++TotLinesRead;
                TotBytesRead += InputLine.Length + 2; // CRLF
                if (SkipLines != 0)
                {
                    if (++LinesSkippedSoFar <= SkipLines)
                    {
                        continue;
                    }
                }
                if (RowsProcessed++ >= MaxRows)
                {
                    break;
                }
                if (HasEOFStr && InputLine.StartsWith(EOFStr))
                {
                    break;
                }
                Fields = Parser.SplitLine(InputLine, RemoveEmbeddedTabs);
                break;
            }
            return(Fields);
        }
Beispiel #2
0
 /// <summary>
 /// Split an input line on the delimeter
 /// </summary>
 /// <remarks>
 /// Input line can have quoted, or non-quoted fields. Both are handled. MUST be delimiter-separated though.
 /// </remarks>
 /// <param name="InputLine"></param>
 /// <param name="Delimiter"></param>
 /// <returns></returns>
 ///
 public static List <string> SplitInputLine(string InputLine)
 {
     if (Cfg.Fixed.IsNullOrEmpty())
     {
         DelimitedLineParser Parser = new DelimitedLineParser(Cfg.Delimiter, Cfg.SimpleParse);
         return(Parser.SplitLine(InputLine, true));
     }
     else
     {
         FixedWidthReader Rdr = new FixedWidthReader();
         return(Rdr.ParseLine(InputLine));
     }
 }