I'm trying to take a SQL file, modify it using R and then save it again in another location. As part of this process, I don't want to modify the formatting.
I've tried using the following (I've stripped the transformation step because it's irrelevant here):
query <- readChar(location, file.info(location)$size)
writeLines(query, file.path(folder$new, script))
Unfortunately, when I do this, the query seems to double all new lines and when I open the newly created .sql file, I get the warning message "The line endings in the following file are not consistent. Do you want to normalize the line endings?"
I've found this question which suggests that it's a combination or CR/LF issues (why i am getting "Inconsistent ending lines" warning window while executing sql script?), but I don't know how to fix/prevent them.
Has anyone had any success in this area? Perhaps a better way of reading .sql files?