I have a self-defined mutable struct as the following.
@enum Fruits Apple Pear Orange
I also have a .csv file, of which the second column is called fruitsCategories, which lists the categories of all the fruits. Then, I need to read this csv file. Now, the second column is of type String. But what I need is this self-defined enumerate type Fruits. So how to accomplish this?
Note: I create this .csv file. So I can add one more column, which is called integerCategory. Then combining with the enumerate type, can get the corresponding category.
But is there any other way then? Because the integerCategory is not really necessary…
EDIT: sorry if I did not explain this clearly. When this .csv file is created, I’m using CSV.write(fln, df)
to write a data frame df
to the file with name fln
. So I think it would be great if I somehow can let Julia know that the column fruitsCategories of of a self-defined type, not of type String.