Basic CSV Import working

This commit is contained in:
BONNEVILLE Geoffroy
2018-09-10 17:29:52 +02:00
parent 34f6d4e793
commit 37deac2ab9
14 changed files with 138 additions and 59 deletions

View File

@@ -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;
}
}
}