using SanShared;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SanSystem
{
    static class HelpFunktion
    {
        public static List<UVcsvStrukture> ParseCSVFile(string csvFile)
        {
            List<UVcsvStrukture> result = new List<UVcsvStrukture>();

            if (!File.Exists(csvFile)) return null;
            string[] input = File.ReadAllLines(csvFile);
            int counter = 0;

            DateTime zeit;
            foreach (string pars in input)
            {
                UVcsvStrukture uVcsvStrukture = new UVcsvStrukture();
                string[] parts = pars.Split(',');
                if (parts[0].Equals("Group1") || parts[1].Equals("(END)")) continue;
                DateTime.TryParse(parts[0], out zeit);
                double temperatur = double.Parse(parts[1].Replace('.', ','));
                double druck = double.Parse(parts[2].Replace('.', ','));
                counter++;

                uVcsvStrukture.Zeitstempel = zeit;
                uVcsvStrukture.Druck = druck;
                uVcsvStrukture.Temperatur = temperatur;
                result.Add(uVcsvStrukture);
            }
            
            return result;
        }
    }
}
