mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Basic CSV Import working
This commit is contained in:
@@ -1,13 +1,35 @@
|
||||
using Windows.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
using ModernKeePass.Interfaces;
|
||||
|
||||
namespace ModernKeePass.ImportFormats
|
||||
{
|
||||
public class CsvImportFormat: IFormat
|
||||
{
|
||||
public IPwEntity Import(IStorageFile source)
|
||||
public bool HasHeaderRow { get; set; } = true;
|
||||
public char Delimiter { get; set; } = ';';
|
||||
public char LineDelimiter { get; set; } = '\n';
|
||||
|
||||
public async Task<List<Dictionary<string, string>>> Import(IStorageFile source)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
var parsedResult = new List<Dictionary<string, string>>();
|
||||
var content = await FileIO.ReadLinesAsync(source);
|
||||
foreach (var line in content)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,16 @@
|
||||
using Windows.Storage;
|
||||
using ModernKeePass.Interfaces;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ModernKeePass.ImportFormats
|
||||
{
|
||||
public class NullImportFormat: IFormat
|
||||
{
|
||||
public IPwEntity Import(IStorageFile source)
|
||||
public Task<List<Dictionary<string, string>>> Import(IStorageFile source)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user