preprocessing
[epclust.git] / data / preprocessing / convert_ts.R
1 convert = function(orig_csv_file, nb_series_per_chunk)
2 {
3 orig_file = file(orig_csv_file, open="r")
4 ignored = readLines(orig_file, 1) #skip header
5
6 serie_length = 17520 #365*24*2
7 library(sqldf, quietly=TRUE)
8 ids = read.csv.sql(file_csv, header = TRUE, sep = ","
9 sql = "select * from file_csv group by FK_CCU_ID")
10 index = 0
11 repeat
12 {
13 if (index+1 >= length(ids))
14 break
15 request = "select CPP_DATE_PUISSANCE,CPP_PUISSANCE_BRUTE where FK_CCU_ID in ("
16 for (id in ids[index + seq_len(nb_series_per_chunk)])
17 request = paste(request, id, ",", sep="")
18 request = paste(request, ") order by FK_CCU_ID,CPP_DATE_PUISSANCE", sep="")
19 series_chunk = read.csv.sql(file_csv, header = TRUE, sep = ",", sql = request)
20
21 index = index + 17520