Skip to content

Commit

Permalink
Fix decimal parsing for non-dot decimal point
Browse files Browse the repository at this point in the history
  • Loading branch information
Rickebo committed Aug 19, 2024
1 parent 125de7d commit 0196419
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
using CsvHelper.Configuration;
using CsvHelper.TypeConversion;
using System;
using System.Globalization;

namespace MatthiWare.YahooFinance.Core.Converters
{
/// <inheritdoc/>
public class DecimalCsvConverter : DefaultTypeConverter
{
/// <inheritdoc/>
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;
}
}
}
}

0 comments on commit 0196419

Please sign in to comment.