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

Spencer Graves @pencer@gr@ve@ @end|ng |rom @tructuremon|tor|ng@com
Sat Oct 16 05:16:47 CEST 2010


  Hi, Nilza:


       Did you receive my reply to your earlier post to R-Help, which 
looks to me identical to this 
(https://stat.ethz.ch/pipermail/r-help/2010-October/256012.html)?  I'd 
like to know if you tried what I suggested there.  If you did, what were 
the results?  If not, why not?


       PLEASE do read the posting guide 
"www.R-project.org/posting-guide.html" and provide commented, minimal, 
self-contained, reproducible code.  Your example is not completely self 
contained.  It might help if you include "sessionInfo()".  In my 
previous reply, there are help pages documenting "dbWriteTable" in 10 
different packages.  I've not used "dbWriteTable" very much, but it 
might help to know which of these 10 packages you are using.



       I've found that following the posting guide often helps me find a 
solution to my problem.  If I still can't solve the problem, this often 
helps me pose the question in a way more likely to generate an answer 
that actually helps me solve the problem.


       I'm sorry if this is not any more helpful than my previous reply.
       Spencer Graves


On 10/15/2010 7:39 PM, Nilza BARROS wrote:
>   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
> *
>
>
> _______________________________________________
> R-sig-DB mailing list -- R Special Interest Group
> R-sig-DB using stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-db


	[[alternative HTML version deleted]]




More information about the R-sig-DB mailing list