Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(DBI)
- library(ODBC)
- m<- read.csv2("C:.../Desktop/TestReport.csv",encoding ="UTF-8")
- #переворачиваем таблицу
- munpivot<- melt(m, id = c("X.U.FEFF.Set.Product.Line","Central.Customer","Month"))
- munpivot[order(munpivot$X.U.FEFF.Set.Product.Line),]
- #очищаем год
- munpivot$variable <- c(sub(".*SOG.MTH.([^&]+).*", "\\1", munpivot$variable))
- #удаляем строки Total
- munpivot <- munpivot[-
- c(as.numeric(rownames
- (subset(munpivot, munpivot$Month=="Total"))
- )
- ),
- ]
- con <- dbConnect(drv = odbc(),
- dbname = "****",
- Driver = "****",
- Server = "****",
- Database = "****",
- UID = "",
- PWD = "",
- encoding = "1252",
- Port = 1433)
- dbWriteTable(conn = con,
- name = "****",
- dbname = "****",
- value = munpivot,
- append = FALSE,
- overwrite = TRUE,
- field.types = NULL)
Advertisement
Add Comment
Please, Sign In to add comment