Spreading Resistance Profile with ChartJS,
Copy-On-Get and nuget bump (Serilog)
This commit is contained in:
72
Server/Services/csv/RawData.cs
Normal file
72
Server/Services/csv/RawData.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Adaptation.FileHandlers.csv;
|
||||
|
||||
public class RawData
|
||||
{
|
||||
|
||||
#nullable disable
|
||||
|
||||
public string TotalPoints { get; set; }
|
||||
public List<Point> Points { get; set; }
|
||||
|
||||
#nullable enable
|
||||
#pragma warning disable CA1834
|
||||
|
||||
internal static RawData? GetRawData(string[] lines, int start, int stop)
|
||||
{
|
||||
RawData? result;
|
||||
Point point;
|
||||
string first;
|
||||
string[] segments;
|
||||
int? secondStart = null;
|
||||
List<Point> points = new();
|
||||
List<string> values = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
for (int i = start; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
first = segments.First();
|
||||
if (first == "Point")
|
||||
{
|
||||
secondStart = i + 1;
|
||||
break;
|
||||
}
|
||||
_ = stringBuilder.Append(first).Append(",");
|
||||
if (segments.Length > 1)
|
||||
values.Add(segments[1]);
|
||||
else
|
||||
values.Add(string.Empty);
|
||||
}
|
||||
string header = "Total Points,";
|
||||
if (secondStart is null || stringBuilder.Length != header.Length || stringBuilder.ToString() != header)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
result = new()
|
||||
{
|
||||
TotalPoints = values[0],
|
||||
Points = points,
|
||||
};
|
||||
for (int i = secondStart.Value; i < stop; i++)
|
||||
{
|
||||
segments = lines[i].Split(new string[] { "," }, StringSplitOptions.None);
|
||||
if (segments.Length < 4)
|
||||
continue;
|
||||
point = new()
|
||||
{
|
||||
Number = segments[0],
|
||||
Depth = segments[1],
|
||||
Resistance = segments[2],
|
||||
StageX = segments[3],
|
||||
StageY = segments[4],
|
||||
StageZ = segments[5],
|
||||
StageT = segments[6],
|
||||
};
|
||||
points.Add(point);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user