diff --git a/src/csv_reader.c b/src/csv_reader.c index f65f86a..7729248 100644 --- a/src/csv_reader.c +++ b/src/csv_reader.c @@ -4,17 +4,19 @@ #include // Conditionals -const bool IS_DEBUG = false; +const bool IS_DEBUG = true; // Constants -const unsigned int BUFFER_SIZE = 2048; -const unsigned int FIELD_SIZE = 20; +const unsigned int BUFFER_SIZE = 620; // (FIELD SIZE = 20) x (NUMBER OF FIELDS = 31) = 620 BYTES // OPTIMIZATION +const unsigned int FIELD_SIZE = 20; // NUMBER OF CHAR PER FIELD const char CSV_DELIMITERS[] = ","; // Globals char** CSV_HEADER_FIELDS; unsigned int CSV_NB_FIELDS; + +//######################################################################## void display_header() { for(unsigned int i = 0; i < CSV_NB_FIELDS; i++) @@ -23,6 +25,8 @@ void display_header() } } + +//######################################################################## void read_csv_header(char * header_line) { int line_length = strlen(header_line); @@ -41,6 +45,7 @@ void read_csv_header(char * header_line) } // Globals allocation + if (IS_DEBUG) printf("number of fields: %d\n",nb_fields); // TO BE REMOVED LATER CSV_NB_FIELDS = nb_fields; CSV_HEADER_FIELDS = malloc( nb_fields * sizeof(char*) ); @@ -58,6 +63,7 @@ void read_csv_header(char * header_line) if (IS_DEBUG) display_header(); } +//######################################################################## void read_csv_file(const char * filename) { FILE* fp = fopen(filename, "r"); @@ -98,11 +104,13 @@ void read_csv_file(const char * filename) fclose(fp); } +//######################################################################## void usage(const char * prog_name) { printf("Usage is %s your_csv_file\n\n", prog_name); } +//######################################################################## int main(int argc, char * argv[]) { if (2 != argc) -- libgit2 0.21.2