Skip to content
Snippets Groups Projects
Commit 49bb54e8 authored by Radek Puš's avatar Radek Puš
Browse files

CsvHelper - set for importing original csv

parent 48ac9e34
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,9 @@ VisualStudioVersion = 16.0.28803.202
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{38DDFEFA-A486-41BA-83C9-E7C30021A980}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NeuralNetwork", "NeuralNetwork\NeuralNetwork.csproj", "{E949B86A-BE3D-481F-ABA4-0FB1C117837B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeuralNetwork", "NeuralNetwork\NeuralNetwork.csproj", "{E949B86A-BE3D-481F-ABA4-0FB1C117837B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImporterCSV", "ImporterCSV\ImporterCSV.csproj", "{D98E5BAE-58A6-43F1-900C-0C8939D089F6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -31,6 +33,14 @@ Global
{E949B86A-BE3D-481F-ABA4-0FB1C117837B}.Release|Any CPU.Build.0 = Release|Any CPU
{E949B86A-BE3D-481F-ABA4-0FB1C117837B}.Release|x64.ActiveCfg = Release|Any CPU
{E949B86A-BE3D-481F-ABA4-0FB1C117837B}.Release|x64.Build.0 = Release|Any CPU
{D98E5BAE-58A6-43F1-900C-0C8939D089F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D98E5BAE-58A6-43F1-900C-0C8939D089F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D98E5BAE-58A6-43F1-900C-0C8939D089F6}.Debug|x64.ActiveCfg = Debug|Any CPU
{D98E5BAE-58A6-43F1-900C-0C8939D089F6}.Debug|x64.Build.0 = Debug|Any CPU
{D98E5BAE-58A6-43F1-900C-0C8939D089F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D98E5BAE-58A6-43F1-900C-0C8939D089F6}.Release|Any CPU.Build.0 = Release|Any CPU
{D98E5BAE-58A6-43F1-900C-0C8939D089F6}.Release|x64.ActiveCfg = Release|Any CPU
{D98E5BAE-58A6-43F1-900C-0C8939D089F6}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -22,22 +22,14 @@ namespace Core
const bool initDB = false; //initialization of database
const bool rebuildDB = false; // drop database; executes only if initDB = true
const bool runClientApp = false;//run ClientApp
const bool runClientApp = true;//run ClientApp
const bool computeCategories = false; //K-means
const bool repetitiveTransaction = false;
const bool ANN = true;
IWebHost host = CreateWebHostBuilder(args).Build();
IServiceProvider services = host.Services.CreateScope().ServiceProvider;
#pragma warning disable CS0162 // Unreachable code detected
if (ANN)
{
//NeuralNetwork neuralNetwork = new NeuralNetwork(services.GetRequiredService<Model>());
////neuralNetwork.test();
//NeuralNetwork.CreateModel();
//neuralNetwork.Train();
}
if (computeCategories)
{
......@@ -61,9 +53,7 @@ namespace Core
#pragma warning restore CS0162 // Unreachable code detected
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args).UseStartup<Startup>();
private static void InitDatabase(IServiceProvider services, bool rebuildDB=false)
{
......
using CsvHelper.Configuration.Attributes;
using System;
using System.Collections.Generic;
using System.Text;
namespace ImporterCSV
{
class DocumentLayout
{
[Name("2")]
public string AccountType { get; set; }
[Name("číslo účtu")]
public string Account { get; set; }
[Name("datum zaúčtování")]
public string Date { get; set; }
[Name("částka")]
public decimal Amount { get; set; }
[Name("měna")]
public string Currency { get; set; }
[Name("zůstatek")]
public string SenderAccountBallance { get; set; }
[Name("číslo účtu protiúčtu")]
public string RecipientAccount { get; set; }
[Name("kód banky protiúčtu")]
public string RecipientBankCode { get; set; }
[Name("název účtu protiúčtu")]
public string RecipientAccountName { get; set; }
[Name("konstantní symbol")]
public string ConstantSymbol { get; set; }
[Name("variabilní symbol")]
public string VariableSymbol { get; set; }
[Name("specifický symbol")]
public string SpecificSymbol { get; set; }
[Name("označení operace")]
public string TransactionType { get; set; }
[Name("ID transakce")]
public long ID { get; set; }
[Name("poznámka")]
public string Note { get; set; }
public string Dump(string delimiter = "\n")
{
string str;
str = AccountType + delimiter;
str+= Account + delimiter;
str += Date.ToString() + delimiter;
str += Amount + delimiter;
str += Currency + delimiter;
str += SenderAccountBallance + delimiter;
str += RecipientAccount + delimiter;
str += RecipientBankCode + delimiter;
str += RecipientAccountName + delimiter;
str += ConstantSymbol + delimiter;
str += VariableSymbol + delimiter;
str += SpecificSymbol + delimiter;
str += TransactionType + delimiter;
str += ID + delimiter;
str += Note;
return str;
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CsvHelper" Version="12.1.2" />
</ItemGroup>
</Project>
using CsvHelper;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace ImporterCSV
{
class Program
{
static void Main(string[] args)
{
IEnumerable<DocumentLayout> records;
using (var reader = new StreamReader("C:\\Users\\Krypton0\\Desktop\\History_01_original.csv"))
using (var csv = new CsvReader(reader))
{
records = csv.GetRecords<DocumentLayout>();
string text = string.Empty;
int i = 0;
foreach (var doc in records)
{
text += doc.Dump(", ") + '\n';
if (i++ > 10)
break;
}
Console.WriteLine(text);
}
}
}
}
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment