preprocessing
authorBenjamin Auder <benjamin.auder@somewhere>
Mon, 6 Mar 2017 09:02:03 +0000 (10:02 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Mon, 6 Mar 2017 09:02:03 +0000 (10:02 +0100)
.gitignore
data/preprocessing/convert_ts.R [new file with mode: 0644]

index f577abe..dbcc2f0 100644 (file)
@@ -1,6 +1,7 @@
 #datasets
 /data/*
 !/data/README
+!/data/preprocessing/
 
 #files generated by initialize.sh
 /.gitfat
diff --git a/data/preprocessing/convert_ts.R b/data/preprocessing/convert_ts.R
new file mode 100644 (file)
index 0000000..6c48b07
--- /dev/null
@@ -0,0 +1,21 @@
+convert = function(orig_csv_file, nb_series_per_chunk)
+{
+       orig_file = file(orig_csv_file, open="r")
+       ignored = readLines(orig_file, 1) #skip header
+
+       serie_length = 17520 #365*24*2
+       library(sqldf, quietly=TRUE)
+       ids = read.csv.sql(file_csv, header = TRUE, sep = ","
+               sql = "select * from file_csv group by FK_CCU_ID")
+       index = 0
+       repeat
+       {
+               if (index+1 >= length(ids))
+                       break
+               request = "select CPP_DATE_PUISSANCE,CPP_PUISSANCE_BRUTE where FK_CCU_ID in ("
+               for (id in ids[index + seq_len(nb_series_per_chunk)])
+                       request = paste(request, id, ",", sep="")
+               request = paste(request, ") order by FK_CCU_ID,CPP_DATE_PUISSANCE", sep="")
+               series_chunk = read.csv.sql(file_csv, header = TRUE, sep = ",", sql = request)
+               
+               index = index + 17520