Commit ea3ccc6d authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

a few more little fixes in read_csv

parent 33d23ef2
...@@ -165,7 +165,7 @@ int CvMLData::read_csv(const char* filename) ...@@ -165,7 +165,7 @@ int CvMLData::read_csv(const char* filename)
if( !fgets_chomp( buf, M, file )) if( !fgets_chomp( buf, M, file ))
{ {
fclose(file); fclose(file);
return 1; return -1;
} }
for( ptr = buf; *ptr != '\0'; ptr++ ) for( ptr = buf; *ptr != '\0'; ptr++ )
cols_count += (*ptr == delimiter); cols_count += (*ptr == delimiter);
...@@ -173,7 +173,7 @@ int CvMLData::read_csv(const char* filename) ...@@ -173,7 +173,7 @@ int CvMLData::read_csv(const char* filename)
if ( cols_count == 0) if ( cols_count == 0)
{ {
fclose(file); fclose(file);
return 1; return -1;
} }
cols_count++; cols_count++;
...@@ -194,18 +194,17 @@ int CvMLData::read_csv(const char* filename) ...@@ -194,18 +194,17 @@ int CvMLData::read_csv(const char* filename)
if (!token) if (!token)
{ {
fclose(file); fclose(file);
return 1; return -1;
} }
for (int i = 0; i < cols_count-1; i++) for (int i = 0; i < cols_count-1; i++)
{ {
str_to_flt_elem( token, el_ptr[i], type); str_to_flt_elem( token, el_ptr[i], type);
var_types_ptr[i] |= type; var_types_ptr[i] |= type;
token = strtok(NULL, str_delimiter); token = strtok(NULL, str_delimiter);
if (!token) if (!token)
{ {
fclose(file); fclose(file);
return 1; return -1;
} }
} }
str_to_flt_elem( token, el_ptr[cols_count-1], type); str_to_flt_elem( token, el_ptr[cols_count-1], type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment