OpenDataVisualizer/Schaad.OpenData.Weather/Source/CsvLine.cs
Claudio Schaad bd2981ffb8 Add live weather layer from MeteoSwiss stations (#7)
- New Schaad.OpenData.Weather project: MeteoSwissClient reads the
  10-minute CSV of the five SwissMetNet stations in Thurgau every 10
  minutes (station list once a day) and backfills the last 7 days from
  the yearly file when the cache has less than 6 days
- History kept as JSON per day (60 days); a failing station does not
  stop the others
- API: /api/weather/meta, /stations (current values, 1 h/24 h rain,
  24 h min/max, strongest gust), /stations/{abbr}/history
- Combined map: "Wetter (live)" layer with station badges (temperature,
  24 h rain or wind), wind arrows, rain marker, station panel with
  hourly 7-day chart, overview and municipality context entries
- Docs: docs/datasets/wetter.md, overview in docs/datasets.md,
  CLAUDE.md; Docker and appsettings wiring

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claudio Schaad <c.schaad@pog.ch>
Co-committed-by: Claudio Schaad <c.schaad@pog.ch>
2026-11-19 05:04:46 +00:00

41 lines
982 B
C#

using System.Text;
namespace Schaad.OpenData.Weather.Source;
internal static class CsvLine
{
public static IReadOnlyList<string> Split(string line)
{
var fields = new List<string>();
var field = new StringBuilder();
var quoted = false;
for (var i = 0; i < line.Length; i++)
{
var c = line[i];
if (c == '"')
{
if (quoted && i + 1 < line.Length && line[i + 1] == '"')
{
field.Append('"');
i++;
}
else
{
quoted = !quoted;
}
}
else if (c == ';' && !quoted)
{
fields.Add(field.ToString());
field.Clear();
}
else
{
field.Append(c);
}
}
fields.Add(field.ToString());
return fields;
}
}