Skip to content

Commit

Permalink
Create setting to declare if insertion file has a header
Browse files Browse the repository at this point in the history
  • Loading branch information
vieirandre committed Jul 6, 2020
1 parent 7c7bb9e commit 1fd9fb0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ public static class Config
public static int TargetPort => int.TryParse(Configuration.GetSection("TargetPort").Value, out int targetPort) ? targetPort : Cassandra.ProtocolOptions.DefaultPort;
public static string TargetKeyspace => Configuration.GetSection("TargetKeyspace").Value;
public static string TargetTable => Configuration.GetSection("TargetTable").Value;
public static string InsertionFilePath => Configuration.GetSection("InsertionFilePath").Value;
public static string ExtractionFilePath => Configuration.GetSection("ExtractionFilePath").Value;
public static string InsertionFilePath => Configuration.GetSection("InsertionFilePath").Value;
public static bool InsertionFileHasHeader => string.Compare(Configuration.GetSection("InsertionFileHasHeader").Value, "true", true) == 0;
public static int InsertionBatch => int.TryParse(Configuration.GetSection("InsertionBatch").Value, out int insertionBatch) ? insertionBatch : 100000;

private static readonly IConfigurationRoot Configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.Build();
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.Build();
}
}
2 changes: 1 addition & 1 deletion Models/Insertion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private static dynamic[] PrepareRowForInsertion(IList<CColumn> columns, List<str
private static void ConfigureCsvReader(CsvReader csvReader)
{
csvReader.Configuration.Delimiter = ",";
csvReader.Configuration.HasHeaderRecord = true;
csvReader.Configuration.HasHeaderRecord = Config.InsertionFileHasHeader;
csvReader.Configuration.MissingFieldFound = null;
}
}
Expand Down
1 change: 1 addition & 0 deletions appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"TargetTable": "",
"ExtractionFilePath": "data/extract.csv",
"InsertionFilePath": "data/insert.csv",
"InsertionFileHasHeader": "",
"InsertionBatch": "100000"
}

0 comments on commit 1fd9fb0

Please sign in to comment.