Skip to content

Instantly share code, notes, and snippets.

@dmarcelinobr
Created January 2, 2014 22:00
Show Gist options
  • Save dmarcelinobr/8227802 to your computer and use it in GitHub Desktop.
Save dmarcelinobr/8227802 to your computer and use it in GitHub Desktop.
This piece loops text files, read them, merge them, and write back a file.
path = "~/Documents/My Data/BRAZIL/Elections/"
out.file<-""
file.names <- dir(path, pattern =".txt")
for(i in 1:length(file.names)){
file <- read.table(file.names[i],header=TRUE, sep=";", stringsAsFactors=FALSE)
out.file <- rbind(out.file, file)
}
write.table(out.file, file = "cand_Brazil.txt",sep=";",
row.names = FALSE, qmethod = "double",fileEncoding="windows-1252")
@Salawol
Copy link

Salawol commented Apr 30, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment