#Split Column
for(i in 1:nrow(data)){
if(!is.na(as.numeric(substring(data$Description[i],first = 0, last = 1)))){

desc = data$Description[i]
pattern = “(PKT|KG|BOT|CTN|NOS)”
pattern2 = ” ”

data$Quantity[i]=substring(desc, first = 0, last = regexpr(pattern, desc)-1)
data$Unit[i]=substring(desc, first = regexpr(pattern, desc),last = regexpr(pattern2,desc))
data$Product[i]=substring(desc, first = regexpr(pattern2, desc)+1)

 

 

Advertisements