Loading .csv file into R Studio with GPS values

0

RStudio Version 1.4.1717.Macintosh; Intel Mac OS X 12_4_0

I'm trying to load a climate .csv file into R studio. All the data appears in the first column. There are no error message but everything I tried doesn't work.

Here's what I've tried : rouyn2005<-read.csv('historique_rouyn_2005_03.csv', header=TRUE, sep=',') rouyn2005<-read.csv('historique_rouyn_2005_03.csv', header=TRUE, sep=';')

I also tried the steps with the 'reader' package with no success.

I would like to join the .csv file but I don't know how.

I'll show the column names and the first line of the file.

Column names Longitude (x),"Latitude (y)","Nom de la Station","ID climatologique","Date/Heure","Année","Mois","Jour","Qualité des Données","Temp max.(°C)","Temp max. Indicateur","Temp min.(°C)","Temp min. Indicateur","Temp moy.(°C)","Temp moy. Indicateur","DJC (°C)","DJC Indicateur","DJR (°C)","DJR Indicateur","Pluie tot. (mm)","Pluie tot. Indicateur","Neige tot. (cm)","Neige tot. Indicateur","Précip. tot. (mm)","Précip. tot. Indicateur","Neige au sol (cm)","Neige au sol Indicateur","Dir. raf. max. (10s deg)","Dir. raf. max. Indicateur","Vit. raf. max. (km/h)","Vit. raf. max. Indicateur"

First line values -79,03,"48,25","ROUYN","7086716","2005-01-03","2005","01","03","","-6,2","","-22,2","","-14,2","","32,2","","0,0","","","M","","M","0,0","","","","33","","37",""

Hope someone could help me with that!

Can you please be more specific, what makes you say "it doesn't work"? we can't help you if we don't know what is your specific problem.

You might try

rouyn2005<-read.csv('historique_rouyn_2005_03.csv',  header=TRUE, 
sep=',',  quote = '"')

However as @ andresrcs says, we need the error messages.

quote already defaults to "\"" so not really a difference there. I think the problem might be that both the first column and first value are not quoted, and the first value uses a comma as the decimal separator. If I manually quote those I get the expected result.

read.csv(text ='"Longitude (x)","Latitude (y)","Nom de la Station","ID climatologique","Date/Heure","Année","Mois","Jour","Qualité des Données","Temp max.(°C)","Temp max. Indicateur","Temp min.(°C)","Temp min. Indicateur","Temp moy.(°C)","Temp moy. Indicateur","DJC (°C)","DJC Indicateur","DJR (°C)","DJR Indicateur","Pluie tot. (mm)","Pluie tot. Indicateur","Neige tot. (cm)","Neige tot. Indicateur","Précip. tot. (mm)","Précip. tot. Indicateur","Neige au sol (cm)","Neige au sol Indicateur","Dir. raf. max. (10s deg)","Dir. raf. max. Indicateur","Vit. raf. max. (km/h)","Vit. raf. max. Indicateur"
"-79,03","48,25","ROUYN","7086716","2005-01-03","2005","01","03","","-6,2","","-22,2","","-14,2","","32,2","","0,0","","","M","","M","0,0","","","","33","","37",""
')
#>   Longitude..x. Latitude..y. Nom.de.la.Station ID.climatologique Date.Heure
#> 1        -79,03        48,25             ROUYN           7086716 2005-01-03
#>   Année Mois Jour Qualité.des.Données Temp.max...C. Temp.max..Indicateur
#> 1  2005    1    3                  NA          -6,2                   NA
#>   Temp.min...C. Temp.min..Indicateur Temp.moy...C. Temp.moy..Indicateur
#> 1         -22,2                   NA         -14,2                   NA
#>   DJC...C. DJC.Indicateur DJR...C. DJR.Indicateur Pluie.tot...mm.
#> 1     32,2             NA      0,0             NA              NA
#>   Pluie.tot..Indicateur Neige.tot...cm. Neige.tot..Indicateur Précip..tot...mm.
#> 1                     M              NA                     M               0,0
#>   Précip..tot..Indicateur Neige.au.sol..cm. Neige.au.sol.Indicateur
#> 1                      NA                NA                      NA
#>   Dir..raf..max...10s.deg. Dir..raf..max..Indicateur Vit..raf..max...km.h.
#> 1                       33                        NA                    37
#>   Vit..raf..max..Indicateur
#> 1                        NA

Created on 2022-07-10 by the reprex package (v2.0.1)

Hi, thank you for that. The thing is this is only the first line of my DF. I have thousands of them. Is there a way to add an argument to the read.csv function ? I also thought about deleting the first numbers i.e. Longitude..x. Latitude..y. I don't those. I found the skip= argument but it's only to skip the first lines.
Is there the equivalent but for the first characters of every single lines ?
Thanks!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.