Message Boards Message Boards

0
|
1727 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to import a column with the quantity days with SemanticImport

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
Posted 1 year 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

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"}]
POSTED BY: Peter Burbery
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract