I want to import a column from a CSV file that is the type quantity. Is there a way to specify the type of quantity, for example, days?
I’ve used the option “DateTime” and “Quantity,” and I used free-form import for days, but that didn’t work.
I read the details of the documentation for semantic import.
How do I tell it to assume the units are in days?
I suspect (but am not positive) that this won’t work the way you describe with SemanticImport. I think you might have better luck applying a function to the data after the import. Since you haven’t provided any sample data to test with, I don’t know exactly what to suggest, but it might be along the lines of
Quantity[#, "Days"] &/@yourdata
That’s basically what I did. I could do something like
data//=Map[Quantity[#,"Days"]&]
This is what I did:
file = File[
"C:\\Users\\Peter\\OneDrive - Marshall \
University\\Documents\\sql.csv"]
semanticData =
SemanticImport[
file, {"DateTime", "DateTime", "DateTime", "Integer", "Integer",
"Currency", "Integer", "String", "String"}, HeaderLines -> 1]
semanticData //=
MapAt[Quantity[#, "Days"] &, {All, "rental_duration"}]