// Copyright (c) 2026 fxtradingguide.com // SPDX-License-Identifier: MIT namespace FxTradingGuide.Studies; /// /// A small reader for the ECB SDMX-CSV file. Fields may be quoted and may contain commas. /// public static class Csv { public static IReadOnlyList ParseLine(string line) { var fields = new List(); var current = new System.Text.StringBuilder(); var inQuotes = false; for (var i = 0; i < line.Length; i++) { var ch = line[i]; if (inQuotes) { if (ch == '"') { if (i + 1 < line.Length && line[i + 1] == '"') { current.Append('"'); i++; } else { inQuotes = false; } } else { current.Append(ch); } } else if (ch == '"') { inQuotes = true; } else if (ch == ',') { fields.Add(current.ToString()); current.Clear(); } else { current.Append(ch); } } fields.Add(current.ToString()); return fields; } }