[R-sig-DB] [R] SQLite: When reading a table, a "\r" is padded onto the last column. Why?

ronggui ronggu|@hu@ng @end|ng |rom gm@||@com
Fri Jan 5 03:02:29 CET 2007


I think there is still one more thins need to do. RSQLite does not
take care of the "NA" (my case: na.strings is  Blank fields in the
test.txt file ) when import from a file to db table.

> library(RSQLite)
Loading required package: DBI
Warning message:
package 'RSQLite' was built under R version 2.4.1
> con <- dbConnect("SQLite", dbname = "c:/test.db3")
> dbWriteTable(con, "test2","c:/test.txt",sep="\t",eol="\r\n",over=T,head=T)
[1] TRUE
> rs <- dbSendQuery(con, "select * from test2")
> fetch(rs)
  a b
1 1 2
2 3 0
3 1 3
4 0 5
5 1 2
6 2 0
7 1 2
> read.table("c:/test.txt",sep="\t",head=T)
   a  b
1  1  2
2  3 NA
3  1  3
4 NA  5
5  1  2
6  2 NA
7  1  2
> dat=read.table("c:/test.txt",sep="\t",head=T)
> dat
   a  b
1  1  2
2  3 NA
3  1  3
4 NA  5
5  1  2
6  2 NA
7  1  2


2007/1/5, Seth Falcon <sfalcon using fhcrc.org>:
> ronggui <ronggui.huang using gmail.com> writes:
> > When write a data frame to db table, the problem of "\r" is fixed. But
> > for importing data frome file, the problem is still there. When if the
> > final line lacks the eol sign "\n", "\001x\001(" comes up.
>
> I've pushed version 0.4-18 to CRAN (should appear in a day or so).
> Importing from text files with and without trailing eol marker should
> be working.
>
> You still have to tell it what eol is.
>
> If you would like to give this new version a try right away, you can
> grab it here:
>
>     http://bioconductor.org/packages/misc/
>
> + seth
>


-- 
Ronggui Huang
Department of Sociology
Fudan University, Shanghai, China
黄荣贵
复旦大学社会学系




More information about the R-sig-DB mailing list