[R-sig-DB] [R] Rmysql - dbWritetable

Nilza BARROS n||z@b@rro@ @end|ng |rom gm@||@com
Sat Oct 16 04:39:40 CEST 2010


 Dear Rusers,

I am trying to feed my database with data from a file.

But since my file (2010101000.txt) there`s no headers I am facing problem
because the
result data.frame is not separated my columns.

How could I set variables names for each columns in *dbWriteTable*? I have
tried the command below but I don`t know how to fill the *field.type*option.


dbWriteTable(con, "b20101010", "./2010101000.txt", overwrite = T, sep =
"\t",row.names=c("V01", "V02", "V03", "V04", "V05", "V06"," V07","V08",
"V09", "V10", "V11", "V12", "V13", "V14"),field.type=????)

===Below what I have been used. I need to know how to set the column names
to xx (my dataframe).

> drv=dbDriver("MySQL")
> con <- dbConnect(drv,dbname='buoy',user="xx",password="xxx")
> dbWriteTable(con, "b20101010", "./2010101000.txt", overwrite = T, sep =
"\t", head = F)
[1] TRUE
>
> *xx*<- dbGetQuery(con, "SELECT * FROM b20101010  ")
> xx

*  V1
*1 00859 2010 10 10 00 50  -41.51   6.83  -9999   1016  -9999 -9999.0
-9999.0 -9999.0
2 00859 2010 10 09 22 50  -41.51   6.81  -9999   1015  -9999 -9999.0 -9999.0
-9999.0
3 00707 2010 10 09 23 00  -34.04 -37.63  -9999   1025  -9999 -9999.0 -9999.0
-9999.0
4 00005 2010 10 09 23 00  -34.69 -18.89  -9999   1017    207     7.2   297.1
-9999.0
5 00859 2010 10 09 23 50  -41.51   6.81  -9999   1015  -9999 -9999.0 -9999.0
-9999.0
6 00005 2010 10 09 23 00  -34.69 -18.89  -9999   1017    207     7.2   297.1
-9999.0
7 00617 2010 10 09 23 20  -18.43 -23.09  -9999   1023  -9999 -9999.0 -9999.0
-9999.0
8 00707 2010 10 10 00 00  -34.03 -37.62  -9999   1025  -9999 -9999.0 -9999.0
-9999.0
9 00707 2010 10 10 01 00  -34.03 -37.62  -9999   1025  -9999 -9999.0 -9999.0
-9999.0
*> length(xx)
[1] 1
*
-- 
Abra�o,
Nilza Barros

	[[alternative HTML version deleted]]




More information about the R-sig-DB mailing list