Hi, I need guidance for converting hourly meteorological data into a specific file format Formatted Text Delimited (*.prn) which is acceptable in the glacier model. I have developed one file in R entitled "TPR-01.prn" code attached in this email. However, it is not similar to what I am trying to develop ( origonal.prn ). Moreover, I also need to place 15 blank rows because glacier model starts to read data from the 18th row. Kindly find data for my case from following link: https://drive.google.com/drive/folders/1gkgIUMEHTrxUuhj5CkpmJ1MRqH1t5KYt?usp=sharing
> dataset <- read.xlsx("test.xlsx",sheet = 2)
> len <- seq(1:17)
> i = 6
> for (i in 6:length(len)) {
> db <- dataset[,c(1:5,i)]
> add
> write.table(db,"TPR-01.prn", sep=paste(rep(" ",6), collapse=""), row.names=F, quote=F)
> }
Is there an format specification available somewhere for prn files, that fully describes it?
There are two parts to your problem: the header, and the data. For the data, the "origonal.prm" file contains several data-time columns, and a single data column. On the other hand, your Excel file contains several data column, named RCM1, RCM2, etc... Is your goal to create a single file for each RCM? Or does the prn file format accept several data columns?
To address the problem of the header, you can work in two steps: first, you write blank lines and header lines using writeLines(); then, you write the data using write.table() with the argument append = TRUE. That way, the data is written after the header.