[英]sqlfetch table not found in channel regular expression
I am trying to find fetch multiple Access files in which the table I need has a different name each time. 我试图找到获取多个Access文件,其中我需要的表每次都具有不同的名称。
Example : 范例:
I tried the following function which will be later used within a map function to fetch all Access files from my directory: 我尝试了以下函数,稍后将在map函数中使用该函数从目录中获取所有Access文件:
fetch <- function (x) { y <- odbcConnectAccess2007(x) sqlFetch(y,"^base.$") odbcCloseAll() }
R does not seem to like regular expressions on sqlfetch
since I get the following message : R似乎不喜欢sqlfetch
上的正则表达式,因为我收到以下消息:
Error in odbcTableExists(channel, sqtable) : '^base.$': table not found on channel odbcTableExists(channel,sqtable)中的错误:'^ base。$':在通道上找不到表
Please note that this works perfectly when I use "base1" as sqltable
instead of "^base.$" 请注意,当我将“ base1”用作sqltable
而不是“ ^ base。$”时,此方法非常有效
Can you help me please ? 你能帮我吗 ?
I have found the solution to this problem : 我已经找到解决此问题的方法:
fetch <- function (x) {
y <- odbcConnectAccess2007(x)
find_table_name <-
str_extract(sqlTables(y)$TABLE_NAME, "^(base.*)$") %>%
na.omit
table_result <- sqlFetch(y, find_table_name[1])
return(table_result)
odbcCloseAll()
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.