Message Boards Message Boards


How to import a column with the quantity days with SemanticImport

Posted 4 months ago
2 Replies
0 Total Likes

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?

POSTED BY: Peter Burbery
2 Replies

That's basically what I did. I could do something like


This is what I did:

file = File[
      "C:\\Users\\Peter\\OneDrive - Marshall \
 semanticData = 
  file, {"DateTime", "DateTime", "DateTime", "Integer", "Integer", 
   "Currency", "Integer", "String", "String"}, HeaderLines -> 1]
semanticData //= 
     MapAt[Quantity[#, "Days"] &, {All, "rental_duration"}]
POSTED BY: Peter Burbery
Posted 3 months ago

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
POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract