SchemaAnalyzer is interpreting Yes/No/Y/N values as Boolean #283
Unanswered
alexandretperez
asked this question in
Q&A
Replies: 2 comments 1 reply
-
|
By design Sylvan/source/Sylvan.Data/SchemaAnalyzer.cs Line 706 in f1c461e |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Adding the TrueString/FalseString to the schema analyzer options would make sense, or you can handle this yourself as in the following example: var dat =
"""
Id,Flag
1,y
2,n
3,n
4,y
""";
var csv = CsvDataReader.Create(new StringReader(dat));
var a = new SchemaAnalyzer();
var result = a.Analyze(csv);
var sb = result.GetSchemaBuilder();
var col = sb[1];
// if it was detected as a boolean, but wasn't "true|false", change it to a string column
if(!StringComparer.OrdinalIgnoreCase.Equals(col.Format, "true|false"))
{
col.SetType(typeof(string));
}
var schema = sb.Build();
Assert.Equal(typeof(string), schema[1].DataType); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I would like to check if we have any control on how SchemaAnalyzer interprets column types.
I have a situation where I'm reading an Excel file which one of the columns can have values as such
Yes, No, Canceled, Transferred.The SchemaAnalyzer interprets the column as string if at least
Canceled/Transferredare present, but if onlyYes/Noare there, the column is interpreted as Boolean.This inconsistence is bad! I don't think
YesandNovalues should be intepreted as Boolean at all. The same applies forY/N.Columns that should hold one single character
A, T, Z, Y, N...also get affected if onlyY/Noccurrences are there.The scenarios I covered testing it was with
Yes/No/Y/N/0/1. The numbers0/1were correctly interpreted as Int32.Is this a bug or it is by design? If it is by design, can we at least have an option in the SchemaAnalyzer to only consider
TRUE/FALSEas real Boolean values?Beta Was this translation helpful? Give feedback.
All reactions