Skip to content

Commit

Permalink
At the end of the file the last line was ignored. Fixed (not in the m…
Browse files Browse the repository at this point in the history
…ost beautiful way).
  • Loading branch information
Björn Hamels committed May 24, 2022
1 parent 745abb3 commit 84ec276
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion PalCSVKnitter/PalCSVFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,15 @@ public int CompareTo(PalCSVFile? other)
return this.first.GetDateTime().CompareTo(other.first.GetDateTime());
}


/// <summary>
/// Converts the file to a list of strings given de stopDateTime and startDateTime.
/// It will (optionally) start at a certain DateTime or Stop at a certain DateTime.
/// </summary>
/// <param name="startDataCount">Start-value of the data count</param>
/// <param name="startStepCount">Start-value of the step count</param>
/// <param name="stopDT">Optional stop at DateTime</param>
/// <param name="startDT">Optional start at DateTime</param>
/// <returns>A tuple containing the list of strings, and the two current stepcounts)</returns>
public (List<string>, long, long) ConvertToListString(long startDataCount, long startStepCount,
DateTime? stopDT, DateTime? startDT)
{
Expand All @@ -106,6 +114,11 @@ public int CompareTo(PalCSVFile? other)
long dataCountMax = 0;
long stepCountMax = 0;

// Aint pretty, this triggers at the last file and make sure that
// the "t < stop" becomes "t <= stop" for the missing last line.
if (startDT.HasValue && !stopDT.HasValue)
stop++;

foreach (PalCSVLine line in lines)
if ((start <= line.Time) && (line.Time < stop)) // t < stop is deliberate to prevent overlap
{
Expand Down

0 comments on commit 84ec276

Please sign in to comment.