mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
CSV Import command created
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
|
||||
namespace ModernKeePass.Infrastructure.File
|
||||
{
|
||||
public class CsvImportFormat: IImportFormat
|
||||
{
|
||||
private const bool HasHeaderRow = true;
|
||||
private const char Delimiter = ';';
|
||||
private const char LineDelimiter = '\n';
|
||||
|
||||
public List<Dictionary<string, string>> Import(IList<string> fileContents)
|
||||
{
|
||||
var parsedResult = new List<Dictionary<string, string>>();
|
||||
foreach (var line in fileContents)
|
||||
{
|
||||
var fields = line.Split(Delimiter);
|
||||
var recordItem = new Dictionary<string, string>();
|
||||
var i = 0;
|
||||
foreach (var field in fields)
|
||||
{
|
||||
recordItem.Add(i.ToString(), field);
|
||||
i++;
|
||||
}
|
||||
parsedResult.Add(recordItem);
|
||||
}
|
||||
|
||||
return parsedResult;
|
||||
}
|
||||
}
|
||||
}
|
@@ -78,7 +78,6 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Common\MachineDateTime.cs" />
|
||||
<Compile Include="DependencyInjection.cs" />
|
||||
<Compile Include="File\CsvImportFormat.cs" />
|
||||
<Compile Include="KeePass\MappingProfiles.cs" />
|
||||
<Compile Include="KeePass\IconMapper.cs" />
|
||||
<Compile Include="KeePass\KeePassDatabaseSettingsProxy.cs" />
|
||||
|
Reference in New Issue
Block a user