Exemplo n.º 1
0
        /// <summary>
        /// Read in a , sepearated ascii file , assumes file is in the same format as the table 
        /// </summary>
        /// <param name="Filename"></param>
        public virtual DataTable LoadFromFile(ArrayList FieldDefs, string Filename)
        {
            DataTable ImporTable = BuildImportTable(FieldDefs);

            CSVtoDataTable tmp = new CSVtoDataTable(ImporTable);
            tmp.LoadfromFile(Filename,System.Text.Encoding.UTF8,true);
            return ImporTable;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Import a csv file to a simple string based datatable
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="incHeader"></param>
        /// <param name="enc"></param>
        /// <returns></returns>
        public static DataTable CovertCSVtoDataTable(string filename, System.Text.Encoding enc, bool incHeader)
        {
            DataTable aTable = new DataTable(System.IO.Path.GetFileNameWithoutExtension(filename).Replace(" ", "_"));

            for(int i = 0 ; i <= 150; i++)
            {
                aTable.Columns.Add(new DataColumn("Field"+i.ToString(), Type.GetType("System.String")));
            }

            CSVtoDataTable tmp = new CSVtoDataTable(aTable);
            tmp.LoadfromFile(filename,enc,incHeader);

            return aTable;
        }