problem opening csv file

hi,
I am trying to open this csv file but it contains information in the first 10 rows, I want to delete these 10 rows, I am also trying to separate the first column into 2, so that one column has the date information and the other the time,

You can use the skip parameter to avoid the first 10 rows, Can you provide a copy/paste friendly sample of your CSV file or a link?

Something like this should work though you may need to change the sep = ","

dat1  <-   read.csv("myfile.csv", sep =",", skip = 10, header = TRUE )
1 Like

Here is an example

library(tidyverse)
library(lubridate)

link <- "https://download.wetransfer.com//us2/6a213cc8828fae9855cc92a5c7574c9920210127015803/1c6bb830012fb796b4457147b87811c6b007e024/meteorolog%C3%ADa_2020.csv?cf=y&token=eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2MTE3MTU1MjIsInVuaXF1ZSI6IjZhMjEzY2M4ODI4ZmFlOTg1NWNjOTJhNWM3NTc0Yzk5MjAyMTAxMjcwMTU4MDMiLCJmaWxlbmFtZSI6Im1ldGVvcm9sb2fDrWFfMjAyMC5jc3YiLCJ3YXliaWxsX3VybCI6Imh0dHA6Ly9wcm9kdWN0aW9uLmJhY2tlbmQuc2VydmljZS51cy1lYXN0LTEud3Q6OTI5Mi93YXliaWxsL3YxL3Nhcmthci83ZWIwYjUyZWJjZjUxNjc5Mzk1NGVhZDRmM2I0OTMzNWJlYTI0ZDdiNGQ0ZWRlYzk0MGYzMzc0Y2NmM2VjNjk4ZmQ5NTFlYTNiNjc4MmZiNTJiYTEzMCIsImZpbmdlcnByaW50IjoiMWM2YmI4MzAwMTJmYjc5NmI0NDU3MTQ3Yjg3ODExYzZiMDA3ZTAyNCIsImNhbGxiYWNrIjoie1wiZm9ybWRhdGFcIjp7XCJhY3Rpb25cIjpcImh0dHA6Ly9wcm9kdWN0aW9uLmZyb250ZW5kLnNlcnZpY2UuZXUtd2VzdC0xLnd0OjMwMDAvd2ViaG9va3MvYmFja2VuZFwifSxcImZvcm1cIjp7XCJ0cmFuc2Zlcl9pZFwiOlwiNmEyMTNjYzg4MjhmYWU5ODU1Y2M5MmE1Yzc1NzRjOTkyMDIxMDEyNzAxNTgwM1wiLFwiZG93bmxvYWRfaWRcIjoxMTMxMDU0MDQxOX19In0.Km8bPuIlLXsRPIxmEGvtclvNpBhaL-4isg3-Iu6NAcw"

sample_df <- read.csv(link, header = TRUE, skip = 10)

sample_df %>%
    separate(date, c("date", "time"), sep = "\\s")
#>          date  time id_station id_parameter value unit
#> 1  01/01/2020 01:00        ACO           RH  70.0    6
#> 2  01/01/2020 01:00        ACO          TMP  11.8    5
#> 3  01/01/2020 01:00        ACO          WDR 340.0    4
#> 4  01/01/2020 01:00        ACO          WSP   0.5    3
#> 5  01/01/2020 01:00        AJU           RH    NA    6
#> 6  01/01/2020 01:00        AJU          TMP    NA    5
#> 7  01/01/2020 01:00        AJU          WDR    NA    4
#> 8  01/01/2020 01:00        AJU          WSP    NA    3
#> 9  01/01/2020 01:00        MON           RH  65.0    6
#> 10 01/01/2020 01:00        MON          TMP  14.9    5

Created on 2021-01-27 by the reprex package (v0.3.0.9001)

2 Likes

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.

country: MĂ©xico
mesurementAgency: SIMAT
URL: http://www.aire.cdmx.gob.mx
timeStamp: 2020/01/01 al 2020/12/31
average_interval: 001h
version:DT003-IAD-20210112-173416
"key: M-FSHOO-NXSM8-D0QN0-4YGKJ "
date id_station id_parameter value unit
01/01/2020 01:00 ACO RH 70 6
01/01/2020 01:00 ACO TMP 11.8 5
01/01/2020 01:00 ACO WDR 340 4
01/01/2020 01:00 ACO WSP 0.5 3
01/01/2020 01:00 AJU RH 6
01/01/2020 01:00 AJU TMP 5
01/01/2020 01:00 AJU WDR 4
01/01/2020 01:00 AJU WSP 3
01/01/2020 01:00 MON RH 65 6
01/01/2020 01:00 MON TMP 14.9 5

and here is the link: