6
$\begingroup$

Bug persisting through 13.1.0


I have a Dataset whose column headers contain Greek letters. If I export the Dataset as a csv file and then SemanticImport that file, the Greek letters appear incorrectly:

    data = Dataset[{ 
            <|"\[Epsilon]" -> 1.5, "\[Eta]" -> 1.0, "\[Nu]u" -> 5.3, "\[Mu]u" -> 3.23, "x0" -> 3.0 |>,
            <|"\[Epsilon]" -> 2.5, "\[Eta]" -> 2.0, "\[Nu]u" -> 5.4, "\[Mu]u" -> 15.3, "x0" -> 4.1 |>
        }];
    Export["test.csv", data, "csv", CharacterEncoding -> "UTF8"];
    data2 = SemanticImport["test.csv", CharacterEncoding -> "UTF8"]

The result is: data2

I can open the csv file with Excel to see that the Greek letters have been exported correctly. They are also imported correctly into Mathematica if I use Import instead of SemanticImport. (I know that I can convert the result of Import into a dataset as a workaround.)

I'm using Mathematica 13.1 on MacOS 11.6 (BigSur).

$\endgroup$

1 Answer 1

6
$\begingroup$

It looks like SemanticImport simply ignores the CharacterEncoding option and imports as "String" instead. Compare with

Import["test.csv", "String"]

"ϵ","η","νu","μu","x0"

1.5,1.,5.3,3.23,3.

2.5,2.,5.4,15.3,4.1

The same is true for SemanticImportString:

SemanticImportString[Import["test.csv", "Text"]]

screenshot

It think it is a bug in SemanticImport, please report it to the official support.

As a workaround, use Import:

Import["test.csv", "Dataset", "HeaderLines" -> 1]

screenshot

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.