Guest User

Untitled

a guest
Nov 6th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. library(DBI)
  2. library(ODBC)
  3.  
  4. m<- read.csv2("C:.../Desktop/TestReport.csv",encoding ="UTF-8")
  5.  
  6. #переворачиваем таблицу
  7. munpivot<- melt(m, id = c("X.U.FEFF.Set.Product.Line","Central.Customer","Month"))
  8. munpivot[order(munpivot$X.U.FEFF.Set.Product.Line),]
  9.  
  10. #очищаем год
  11. munpivot$variable <- c(sub(".*SOG.MTH.([^&]+).*", "\\1", munpivot$variable))
  12.  
  13. #удаляем строки Total
  14. munpivot <- munpivot[-
  15. c(as.numeric(rownames
  16. (subset(munpivot, munpivot$Month=="Total"))
  17. )
  18. ),
  19. ]
  20.  
  21. con <- dbConnect(drv = odbc(),
  22. dbname = "****",
  23. Driver = "****",
  24. Server = "****",
  25. Database = "****",
  26. UID = "",
  27. PWD = "",
  28. encoding = "1252",
  29. Port = 1433)
  30.  
  31.  
  32. dbWriteTable(conn = con,
  33. name = "****",
  34. dbname = "****",
  35. value = munpivot,
  36. append = FALSE,
  37. overwrite = TRUE,
  38. field.types = NULL)
Advertisement
Add Comment
Please, Sign In to add comment