Пример #1
0
        static void Main(string[] args)
        {
            string sourcepath = args[0];

            // there are a few static utility functions
            Console.WriteLine("The given DAT file has {0} rows.", DelimitedFile.GetRowCount(sourcepath));
            Console.WriteLine("The first row: {0}", DelimitedFile.GetFirstRow(sourcepath));

            // initialize the reader, given the file to read from and that this file a header row
            DelimitedFile file = new DelimitedFile(sourcepath, true);

            // set delimiter values (these are the defaults)
            file.NewlineCharacter = 10;
            file.TextQualifierCharacter = 254;
            file.CarriageReturnCharacter = 13;
            file.ColumnDelimiterCharacter = 20;

            // read in and handle an available line from the file
            while (file.ReadRow())
            {
                if (file.CurrentRowNumber == 1)
                {
                    Console.WriteLine("Column headers: {0}", string.Join(", ", file.CurrentRow.Columns));
                    continue;
                }
                else
                {
                    if (file.SetColumnValue("text", "example"))
                    {
                        Console.WriteLine(file.GetColumnValue("text"));
                    }
                }
            }
        }
        public static DelimitedFileRow GetFirstRow(string p_path)
        {
            DelimitedFile file = new DelimitedFile(p_path);

            if (file.ReadRow())
            {
                return(file.CurrentRow);
            }

            return(null);
        }
        public static int GetRowCount(string p_path, bool p_hasHeaders = true)
        {
            int           rowCount = 0;
            DelimitedFile file     = new DelimitedFile(p_path, p_hasHeaders, true);

            while (file.ReadRow())
            {
                rowCount++;

                if (p_hasHeaders == true && file.CurrentRowNumber == 1)
                {
                    rowCount--;
                }
            }

            return(rowCount);
        }
Пример #4
0
        public static int GetRowCount(string p_path, bool p_hasHeaders = true)
        {
            int rowCount = 0;
            DelimitedFile file = new DelimitedFile(p_path, p_hasHeaders, true);

            while (file.ReadRow())
            {
                rowCount++;

                if (p_hasHeaders == true && file.CurrentRowNumber == 1)
                {
                    rowCount--;
                }
            }

            return rowCount;
        }
Пример #5
0
        public static DelimitedFileRow GetFirstRow(string p_path)
        {
            DelimitedFile file = new DelimitedFile(p_path);

            if (file.ReadRow())
            {
                return file.CurrentRow;
            }

            return null;
        }