Skip to content

Commit

Permalink
fix: csv import
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirdock committed Aug 3, 2021
1 parent a85ef42 commit 85e1d92
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
9 changes: 6 additions & 3 deletions DataTableConverter/Assisstant/DatabaseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,16 +486,19 @@ internal SQLiteCommand InsertDuplicateCommand(string[] headers, string tableName
return command;
}

internal SQLiteCommand InsertRow(IEnumerable<string> eHeaders, object[] values, string tableName, SQLiteCommand cmd = null)
internal SQLiteCommand InsertRow(IEnumerable<string> eHeaders, object[] values, string tableName, SQLiteCommand command = null)
{
string[] headers = eHeaders.ToArray();
if (headers.Length > values.Length)
{
headers = headers.Take(values.Length).ToArray();
cmd = null;
command = null;
}
if(command?.Parameters.Count != values.Length)
{
command = null;
}

SQLiteCommand command = cmd;
if (command == null)
{
string headerString = GetHeaderString(headers);
Expand Down
15 changes: 13 additions & 2 deletions DataTableConverter/Assisstant/ImportHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,25 @@ internal void OpenText(string tableName, string path, List<string> separators, i
var indexItem = newHeaders.Select((item, index) => new { item, index });
for (int i = 0; i < newHeaders.Count; ++i)
{
var duplicates = indexItem.Where(element => element.index != i && element.item.Equals(newHeaders[i], StringComparison.OrdinalIgnoreCase)).ToArray();
var duplicates = indexItem.Where(element => element.item == string.Empty || element.index != i && element.item.Equals(newHeaders[i], StringComparison.OrdinalIgnoreCase)).ToArray();
for(int y = 0; y < duplicates.Length; ++y)
{
int counter = y + 2;
string newValue;
string item = duplicates[y].item; ;
string header;
if(item == string.Empty)
{
header = "Spalte";
counter--;
}
else
{
header = item;
}
do
{
newValue = duplicates[y].item + counter;
newValue = header + counter;
++counter;
} while (newHeaders.Contains(newValue));

Expand Down
2 changes: 1 addition & 1 deletion DataTableConverter/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.6.0")]
[assembly: AssemblyFileVersion("1.0.7.0")]

0 comments on commit 85e1d92

Please sign in to comment.