Example #1
0
        public CTEnum InferType(CsvColumnType t)
        {
            if (t.IsTime)
                return CTEnum.DateTime;
            if (t.IsDate)
            {
                return CTEnum.DateTime;
            }
            if (t.IsInt32)
            {
                return CTEnum.Int32;
            }
            if (t.IsInt64)
            {
                return CTEnum.Int64;
            }
            if (t.IsDecimal)
            {
                return CTEnum.Decimal;
            }
            if (t.IsDouble)
            {
                return CTEnum.Double;
            }
            if (t.IsString)
            {
                return CTEnum.String;
            }

            throw new InvalidDataException("Unknown data type in column");
        }
Example #2
0
        public static CsvColumnType ColumnTypeCreate(string s)
        {

            try
            {
                var t = new CsvColumnType
                {
                    IsDate = CheckDate(s),
                    IsTime = CheckTime(s),
                    IsDecimal = CheckDecimal(s),
                    IsDouble = CheckDouble(s),
                    IsInt32 = CheckInt32(s),
                    IsInt64 = CheckInt64(s),
                    IsNull = CheckForNull(s)
                };
                t.IsString = !(t.IsDate || t.IsDecimal || t.IsInt32 || t.IsInt64 || t.IsTime);

                return t;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return null;
        }