From 0196419d93c7b66d3cb8c11342c3476bab852c8f Mon Sep 17 00:00:00 2001 From: Simon Pettersson Date: Mon, 19 Aug 2024 18:31:13 +0200 Subject: [PATCH] Fix decimal parsing for non-dot decimal point --- .../Core/Converters/DecimalCsvConverter.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/YahooFinance.Core/YahooFinance.Core/Core/Converters/DecimalCsvConverter.cs b/YahooFinance.Core/YahooFinance.Core/Core/Converters/DecimalCsvConverter.cs index 654e6ab..9cb910e 100644 --- a/YahooFinance.Core/YahooFinance.Core/Core/Converters/DecimalCsvConverter.cs +++ b/YahooFinance.Core/YahooFinance.Core/Core/Converters/DecimalCsvConverter.cs @@ -2,6 +2,7 @@ using CsvHelper.Configuration; using CsvHelper.TypeConversion; using System; +using System.Globalization; namespace MatthiWare.YahooFinance.Core.Converters { @@ -9,14 +10,15 @@ namespace MatthiWare.YahooFinance.Core.Converters public class DecimalCsvConverter : DefaultTypeConverter { /// - public override object ConvertFromString(string text, IReaderRow row, MemberMapData memberMapData) + public override object ConvertFromString( + string text, + IReaderRow row, + MemberMapData memberMapData + ) { - if (!decimal.TryParse(text, out var convertedDecimal)) - { - return decimal.MinValue; - } - - return convertedDecimal; + return decimal.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out var convertedDecimal) + ? convertedDecimal + : decimal.MinValue; } } -} +} \ No newline at end of file