public List <DcColumn> LoadSchema() // Table object is created to store all necessary parameters which are individual for each table { TableCsv table = this; List <DcColumn> columns = new List <DcColumn>(); if (table.FilePath == null || !File.Exists(table.FilePath)) // File might not have been created (e.g., if it is an export file) { return(columns); } // TODO: We should not use connection - use TableReader/TableWriter where necessary (connection is hidden within them) ConnectionCsv connection = new ConnectionCsv(); connection.OpenReader(table); List <string> names = connection.ReadColumns(); List <string[]> sampleRows = connection.ReadSampleValues(); for (int i = 0; i < names.Count; i++) { string columnName = names[i]; DcTable type = this.Schema.GetPrimitiveType("String"); ColumnCsv column = (ColumnCsv)Space.CreateColumn(DcSchemaKind.Csv, columnName, table, type, false); //DcColumn column = Space.CreateColumn(columnName, table, type, false); columns.Add(column); // Properties specific to this column type column.ColumnIndex = i; var values = new List <string>(); foreach (var row in sampleRows) { values.Add(row[i]); } column.SampleValues = values; } connection.CloseReader(); return(columns); }
public TableWriterCsv(DcTable table) { this.table = table; connectionCsv = connectionCsv = new ConnectionCsv(); }
public TableReaderCsv(DcTable table) { this.table = table; connectionCsv = new ConnectionCsv(); }
public SchemaCsv(string name, DcSpace space) : base(name, space) { _schemaKind = DcSchemaKind.Csv; connection = new ConnectionCsv(); }