ademant 2019-05-27 19:18:04 +02:00
commit 5007ccba05
1 changed files with 19 additions and 0 deletions

19
import_sql.r Normal file
View File

@ -0,0 +1,19 @@
library(foreach)
indata<-read.table("/home/pi/rasolar/data_433046.txt",fill=TRUE,stringsAsFactors=FALSE)
raw_dat=unlist(sapply(1:nrow(indata),function(i){return(strsplit(indata[i,],";")[[1]])}))
var_names=unique(sapply(1:length(raw_dat),function(i){return(head(strsplit(raw_dat[i],":")[[1]],1))}))
raw_row=as.data.frame(t(as.data.frame(rep(NA,length(var_names)))))
names(raw_row)<-var_names
intable<-foreach(i=1:nrow(indata),.combine=rbind)%do%{
tid<-strsplit(indata[i,],";")[[1]]
tout<-raw_row
for(j in tid){
ttid<-strsplit(j,":")[[1]]
tout[ttid[1]]<-as.numeric(ttid[2])
}
return(tout)
}