使用 R 编辑 .sql 文件
我正在尝试获取一个 SQL 文件,使用 R 修改它,然后再次将其保存在另一个位置。作为此过程的一部分,我不想修改格式。
我尝试使用以下内容(我删除了转换步骤,因为它在这里无关紧要):
query <- readChar(location, file.info(location)$size)
writeLines(query, file.path(folder$new, script))
不幸的是,当我这样做时,查询似乎将所有新行加倍,当我打开新创建的 .sql 文件时,我得到警告消息“以下文件中的行结尾不一致。是否要标准化行结尾?”
我发现这个问题表明它是组合或 CR/LF 问题(为什么我在执行 sql 脚本时收到“不一致的结束行”警告窗口?),但我不知道如何修复/防止它们。
有人在这个领域取得过成功吗?也许有更好的读取 .sql 文件的方法?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论