Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. setDir := Quiet@Check[SetDirectory@DirectoryName@$InputFileName, SetDirectory@NotebookDirectory[]]
  2.  
  3. path = FileNameJoin[{setDir, "Input Workbook.xlsx"}]
  4.  
  5. firsttable = SemanticImport[path, <|"Wine" -> Automatic, "Brand" -> Automatic|>, HeaderLines -> 1]
  6.  
  7. secondtable = SemanticImport[path, <|"Brands" -> Automatic, "Color" -> String, "Bouquet" -> String|>, HeaderLines -> 1] // Take[#, 5] &
  8.  
  9. rls = Append[# :> {##2} & @@@ Normal[secondtable], _ -> {None, None}] // Dispatch
  10.  
  11. wine = firsttable[All, "Wine"];
  12.  
  13. wine2 = Table[wine [[i]], {i, 1, Length[wine]}]
  14.  
  15. brand = firsttable[All, "Brand"];
  16.  
  17. brand2 = Table[brand[[i]], {i, 1, Length[brand]}]
  18.  
  19. need = Transpose[{wine2, brand2}]
  20.  
  21. ds = Dataset[Join[need, Replace[Normal[firsttable[[All, 2]]], rls, {1}], 2]]
  22.  
  23. finaltable = ds[All, <|"Wine" -> 1, "Brand" -> 2, "Color" -> 3, "Bouquet" -> 4|>]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement