Re: [R] Help with read.csv.sql()

2020-07-30 Thread H
On 07/30/2020 06:09 PM, Gabor Grothendieck wrote: > Probably simplest to assign the names afterwards as others have > suggested but it could be done like this: > > library(sqldf) > write.csv(BOD, "BOD.csv", quote = FALSE, row.names = FALSE) # test data > > read.csv.sql("BOD.csv", "select Tim

Re: [R] Help with read.csv.sql()

2020-07-30 Thread Gabor Grothendieck
Probably simplest to assign the names afterwards as others have suggested but it could be done like this: library(sqldf) write.csv(BOD, "BOD.csv", quote = FALSE, row.names = FALSE) # test data read.csv.sql("BOD.csv", "select Time as Time2, demand as demand2 from file") giving the column n

Re: [R] Help with read.csv.sql()

2020-07-29 Thread Rasmus Liland
On 2020-07-29 22:56 +0200, Ulrik Stervbo wrote: > So, 50% on topic :-) I guess so haha :-) Still I hope this is useful for H , others, or he solved it but still no bottom line volatile situation open for new ideas. __ R-help@r-project.org mailing l

Re: [R] Help with read.csv.sql()

2020-07-29 Thread Ulrik Stervbo via R-help
True, but the question was also how to control for formats and naming columns while loading the file. The only way I know how to do this (sans work on my part) is through the functions in readr. So, 50% on topic :-) Best, Ulrik On 29 Jul 2020, 17:59, at 17:59, Rasmus Liland wrote: >Dear Ulri

Re: [R] Help with read.csv.sql()

2020-07-29 Thread Rasmus Liland
Dear Ulrik, On 2020-07-29 17:14 +0200, Ulrik Stervbo via R-help wrote: > library(readr) > read_csv( This thread was about sqldf::read.csv.sql ... What is the purpose of bringing up readr::read_csv? I am unfamilliar with it, so it might be a good one. Best, Rasmus signature.asc Descriptio

Re: [R] Help with read.csv.sql()

2020-07-29 Thread Ulrik Stervbo via R-help
You might achieve this using readr: ``` library(readr) lines <- "Id, Date, Time, Quality, Lat, Long STM05-1, 2005/02/28, 17:35, Good, -35.562, 177.158 STM05-1, 2005/02/28, 19:44, Good, -35.487, 177.129 STM05-1, 2005/02/28, 23:01, Unknown, -35.399, 177.064 STM05-1, 2005/03/01, 07:

Re: [R] Help with read.csv.sql()

2020-07-29 Thread Ulrik Stervbo via R-help
You might achieve this using readr: ``` library(readr) lines <- "Id, Date, Time, Quality, Lat, Long STM05-1, 2005/02/28, 17:35, Good, -35.562, 177.158 STM05-1, 2005/02/28, 19:44, Good, -35.487, 177.129 STM05-1, 2005/02/28, 23:01, Unknown, -35.399, 177.064 STM05-1, 2005/03/01, 07:

Re: [R] Help with read.csv.sql()

2020-07-20 Thread Rasmus Liland
On 2020-07-20 17:54 -0400, H wrote: > On 07/18/2020 11:42 PM, Rasmus Liland wrote: > > > > The thing is, defining the second column > > as of type Date in colClasses happens to > > work, but it's still character when you > > check with str(dat) ... perhaps it has > > something to do with this i

Re: [R] Help with read.csv.sql()

2020-07-20 Thread H
On 07/18/2020 11:42 PM, Rasmus Liland wrote: > On 2020-07-18 18:09 +0100, Rui Barradas wrote: > | �s 17:59 de 18/07/2020, H escreveu: > | | On Fri, Jul 17, 2020 at 6:28 PM H wrote: > | | | > | | | The problem I am having is that > | | | the csv files have header rows > | | | with column names t

Re: [R] Help with read.csv.sql()

2020-07-19 Thread H
On 07/18/2020 01:38 PM, William Michels wrote: > Do either of the postings/threads below help? > > https://r.789695.n4.nabble.com/read-csv-sql-to-select-from-a-large-csv-file-td4650565.html#a4651534 > https://r.789695.n4.nabble.com/using-sqldf-s-read-csv-sql-to-read-a-file-with-quot-NA-quot-for-mis

Re: [R] Help with read.csv.sql()

2020-07-18 Thread Rasmus Liland
On 2020-07-18 18:09 +0100, Rui Barradas wrote: | Às 17:59 de 18/07/2020, H escreveu: | | On Fri, Jul 17, 2020 at 6:28 PM H wrote: | | | | | | The problem I am having is that | | | the csv files have header rows | | | with column names that are | | | slightly different from the column | | | na

Re: [R] Help with read.csv.sql()

2020-07-18 Thread William Michels via R-help
Do either of the postings/threads below help? https://r.789695.n4.nabble.com/read-csv-sql-to-select-from-a-large-csv-file-td4650565.html#a4651534 https://r.789695.n4.nabble.com/using-sqldf-s-read-csv-sql-to-read-a-file-with-quot-NA-quot-for-missing-td4642327.html Otherwise you can try reading thr

Re: [R] Help with read.csv.sql()

2020-07-18 Thread Rui Barradas
Hello, The documentation says the following. field.types A list whose names are the column names and whose contents are the SQLite types (not the R class names) of the columns. So argument field.types is a named list.  - The list members names are the column names of the table to be read.  

Re: [R] Help with read.csv.sql()

2020-07-18 Thread H
On 07/18/2020 11:54 AM, Rui Barradas wrote: > Hello, > > I don't believe that what you are asking for is possible but like Bert > suggested, you can do it after reading in the data. > You could write a convenience function to read the data, then change what you > need to change. > Then the functi

Re: [R] Help with read.csv.sql()

2020-07-18 Thread Rui Barradas
Hello, I don't believe that what you are asking for is possible but like Bert suggested, you can do it after reading in the data. You could write a convenience function to read the data, then change what you need to change. Then the function would return this final object. Rui Barradas Às 16

Re: [R] Help with read.csv.sql()

2020-07-18 Thread H
On 07/17/2020 09:49 PM, Bert Gunter wrote: > Is there some reason that you can't make the changes to the data frame > (column names, as.date(), ...) *after* you have read all your data in? > > Do all your csv files use the same names and date formats? > > > Bert Gunter > > "The trouble with having

Re: [R] Help with read.csv.sql()

2020-07-17 Thread Bert Gunter
Is there some reason that you can't make the changes to the data frame (column names, as.date(), ...) *after* you have read all your data in? Do all your csv files use the same names and date formats? Bert Gunter "The trouble with having an open mind is that people keep coming along and stickin