Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206305

Is there a way to open .csv in R skipping the first X rows, where X is variable based on where specified headers can be found?

$
0
0

I am trying to read a number of .csv files within a folder and combine all of the data into one data frame for analysis and graphing. Generally, I would use this approach in order to load and combine all of the files.

    file_list <- list.files(paste(WorkingDirectory, "/Transducer Data", sep= ""), pattern = "*.csv", 
    full.names = TRUE)

    for (file in file_list){
       all_transducer_file <- read.csv(file, header = F, as.is = T, sep= ",", skip = 15) 
     }

However, I am encountering a couple of issues.
1. The .csv that are generated have differing number of rows before the data. The headers for the data appear to always be: "Date and Time", "Seconds", "Pressure (PSI)", and "Surface Water Level (ft)". The number of rows varies based on how many errors were thrown by the device since the last data pull. 2. The data is sometimes loaded as "chr" type and sometimes as "factor" type. I don't really understand the difference between those or how that might affect the coding.

Is there a way to open csv skipping the first X rows, where X is based on where specified headers can be found?


Viewing all articles
Browse latest Browse all 206305

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>