private TextDataReader _GetDataReader() { DataTable dt = new DataTable(); foreach (var col in Columns) { dt.Columns.Add(col); } return(new TextDataReader(FileName, null, FieldTerminator.GetChar(), FieldQuotationCharacter.GetChar(), dt, null, TextDataReader.TrimMode.Both)); }
private string _BuildPostgreSQLCommand() { StringBuilder builder = new StringBuilder(); builder.Append($@"COPY {TableName} "); if (Columns.Count > 0) { builder.Append($"({Columns.ToArray().ToStr(',')}) "); } builder.Append($"FROM STDIN "); //builder.Append($"'{FileName.Replace(@"\", @"/")}' "); StringBuilder builder2 = new StringBuilder(); if (NumberOfLinesToSkip > 0) { builder2.Append("HEADER true "); } else { builder2.Append("HEADER false "); } //builder2.Append(",FORMAT 'CSV'"); if (FieldTerminator + "" != "") { builder2.Append($",DELIMITER '{FieldTerminator.GetChar()}' "); } //if (FieldQuotationCharacter + "" != "") //{ // builder2.Append($",QUOTE '{FieldQuotationCharacter}' "); //} if (EscapeCharacter + "" != "" && EscapeCharacter != "\\") { builder2.Append($",ESCAPE '{EscapeCharacter}' "); } if (this.CharacterSet + "" != "") { builder2.Append($",ENCODING '{this.CharacterSet}' "); } builder.Append($"WITH({builder2}) "); return(builder.ToString()); }