2
I have a code that takes a txt file with ";" delimiter and swaps it with "/t". However, in these 90 files, there are fields with id = 01,02,03,04 ... When I change bounders the fields with the id above comes 1,2,3,4,5. It happens that I need these zeros in front of these id.
fns = list.files(patt="\\.txt")
n <- length(fns) # Conta o numero de itens na lista
for (i in 1:n){
dado1 <- read.table(fns[i], head=T,sep=";",encoding = "UTF-8")
names(dado1)[grep("ï..ID", names(dado1))] <- "ID"
names(dado1)[grep("X.U.FEFF.ID", names(dado1))] <- "ID"
#dado1$FL_INPUT[which( is.na(dado1$FL_INPUT))] <- "1"
excluir <- c("FL_INPUT", "FL_VALIDACAO_LISTAGEM")
dado1 <- dado1[,!(names(dado1)%in% excluir)]
write.table(dado1, fns[i], sep="\t", row.names = FALSE, quote=FALSE, na= "", dec = ",")
}
Thank you very much bro resolved <3
– Matheus Santos
Good :) don’t forget to accept the answer then
– rhenesys