add some prints in convert_to_CSV.c; almost working. TODO...
authorBenjamin Auder <benjamin.auder@somewhere>
Fri, 17 Mar 2017 16:18:04 +0000 (17:18 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Fri, 17 Mar 2017 16:18:04 +0000 (17:18 +0100)
data/preprocessing/convert_to_CSV.c

index 34cb6e4..df31f71 100644 (file)
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <math.h>
 #include <float.h>
+#include <stdio.h>
 
 // Read an integer char by char, and position the cursor to next character
 char readInt(FILE* stream, int* integer)
@@ -15,8 +16,13 @@ char readInt(FILE* stream, int* integer)
                nextChar = fgetc(stream);
        ungetc(nextChar, stream);
        while ((nextChar = fgetc(stream)) >= '0' && nextChar <= '9')
-               *integer = 10 * (*integer) + (int) (nextChar - '0');
+       {
+
+       printf("next char: %c\n",nextChar);
+
+               *integer = 10 * (*integer) + (int) (nextChar - '0'); }
        (*integer) *= sign;
+printf("INTEGER: %i\n",*integer);
        return nextChar;
 }
 
@@ -113,13 +119,13 @@ int transform(const char* ifileName, int posID, int posValue,
 
                // Read current line
                scan_line(ifile, sep, posID, &ID, posValue, &value);
+
+               printf("SCAN: %i %g\n",ID,value);
                if (ID != lastID)
                {
                        // Just starting a new time-series: must process the last one (if exists !)
                        if (lastID > 0)
                        {
-                               if (refTsLength == 0)
-                                       refTsLength = tsLength; //first serie is considered clean
                                if (tsLength == refTsLength)
                                {
                                        for (int i=0; i<tsLength; i++)
@@ -135,12 +141,14 @@ int transform(const char* ifileName, int posID, int posValue,
                                else
                                        mismatchLengthCount++;
                        }
+                       else
+                               refTsLength = tsLength; //first serie is considered clean
 
                        // reinitialize flags
                        tsLength = 0;
                        lastID = ID;
                }
-
+printf("LA %i %i\n",tsLength,refTsLength);
                //We cannot write more than refTsLength values
                if (tsLength < refTsLength)
                        tsBuffer[tsLength++] = value;