9511_project01

project 1 for algorithms & programming I (9511) prof. Cardozo
Index Commits Files Refs README
commit cd9a8a2ac9472513286d5222331055b3501b1cc6
parent a6e6a73ea1dc5c230aed96659e6b831f89029819
Author: Martin J. Klöckner <64109770+klewer-martin@users.noreply.github.com>
Date:   Tue,  9 Feb 2021 20:13:42 -0300

Merge pull request #10 from klewer-martin/alpha

Alpha
Diffstat:
MMakefile | 21++++++++++++---------
MREADME.md | 28+++++++++++++++++++++++++---
Minput.csv | 13+++++++++++++
Mload_country_codes.h | 2--
Mmacros.h | 2++
Mmain.c | 60++++++++++++++++++++++++++++++++++++++++++++++++------------
Mmain.h | 27+++++++++++++++++++++++++--
Amake.bat | 12++++++++++++
Moutput.txt | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aprint_file.c | 115+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aprint_file.h | 20++++++++++++++++++++
Aread_file.c | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aread_file.h | 21+++++++++++++++++++++
Dreadlines.c | 189-------------------------------------------------------------------------------
Dreadlines.h | 30------------------------------
15 files changed, 432 insertions(+), 247 deletions(-)
diff --git a/Makefile b/Makefile
@@ -4,27 +4,30 @@ CFLAGS = -std=c99 -Wall -pedantic
 all: main clean
 
 
-main: main.o arguments.o perrors.o load_country_codes.o readlines.o
-    $(CC) $(CFLAGS) main.o arguments.o perrors.o load_country_codes.o readlines.o -o main 
+main: main.o arguments.o perrors.o load_country_codes.o read_file.o print_file.o
+    $(CC) $(CFLAGS) main.o arguments.o perrors.o load_country_codes.o read_file.o print_file.o -o main 
 
 main.o: main.c main.h arguments.h macros.h
-    $(CC) -c main.c
+    $(CC) $(CFLAGS) -c main.c
 
 arguments.o: arguments.c arguments.h macros.h
-    $(CC) -c arguments.c
+    $(CC) $(CFLAGS) -c arguments.c
 
 perrors.o: main.c main.h
-    $(CC) -c perrors.c
+    $(CC) $(CFLAGS) -c perrors.c
 
 load_country_codes.o: load_country_codes.h main.h
-    $(CC) -c load_country_codes.c 
+    $(CC) $(CFLAGS) -c load_country_codes.c 
 
-readlines.o: readlines.h main.h
-    $(CC) -c readlines.c
+read_file.o: read_file.h main.h
+    $(CC) $(CFLAGS) -c read_file.c
+
+print_file.o: print_file.h main.h
+    $(CC) $(CFLAGS) -c print_file.c
 
 
 clean:
     rm -f *.o 
 
 run: 
-    ./main -in input.csv
+    ./main -in input.csv -out output.txt
diff --git a/README.md b/README.md
@@ -1,4 +1,4 @@
-# PROJECT NUMBER 1 - ALGORITHMS & PROGRAMMING I
+# PROJECT 01 - ALGORITHMS & PROGRAMMING I (95.11)
 
 This folder contains the first project of "Algoritmos y 
 Programacion I" a subject from Facultad de Ingenieria de la
@@ -7,13 +7,36 @@ runs on CLI which its function is to process data entered via
 a .csv file.
 
 What it does is receive a number for a country, date, and number of
-cases (of COVID19), and prints it on stdout with a human readable
+cases (of COVID19), and prints it on a file with a human readable
 format.
 
 Bibliography:
 
 "The C programming language" - Brian W. Kernighan & Dennis Ritchie.
 
+Installation:
+
+NOTE: You need to have installed gcc in order to compile the application.  
+Install it and make shure you have gcc added to path to execute it from
+terminal/cmd.
+
+Arch based distros:
+    
+    Install base-devel, git(not neccesary unless you want to clone the repo).
+         
+    Clone repo from terminal or download the .zip file and unzip it.
+         
+    Navigate to the folder and open a terminal there, run 'make install'.
+
+Windows installation:
+
+    Downlaod .zip file and unzip it or clone repo.
+    
+    Navigate to the downloaded folder.
+    
+    Execute 'make.bat'.
+
+    
 NAME
     analisis_covid - analyze RAW data and export it with a human 
     readable format.
@@ -26,7 +49,6 @@ DESCRIPTION
     Process RAW data from a .csv(comma separated values) file,
     and export it to another .csv file, if the output file doesn't
     exist then it creates one with the specified name.
-
     When you invoke analisis_covid, expects.. to be continued
 
 
diff --git a/input.csv b/input.csv
@@ -2,9 +2,22 @@ PAIS, FECHA, INFECTADOS
 32,1577880000,2342
 32,1578657600,4923
 32,1579089600,9324
+32,1581223358,9324
+32,1581741758,7324
+32,1582864958,4324
 170,1577880000,8234
 170,1578657600,9234
 170,1579089600,9423
+170,1579089600,9423
 276,1577880000,8432
 276,1579089600,9129
 276,1579521600,4214
+276,1581223358,9324
+276,1581741758,7324
+276,1582864958,4324
+36,1577880000,3
+36,1579089600,7
+36,1579521600,16
+36,1581223358,33
+36,1581741758,88
+36,1582864958,162
diff --git a/load_country_codes.h b/load_country_codes.h
@@ -3,8 +3,6 @@
 
 #include "main.h"
 
-#define COUNTRIES_NUMBER    1000
-#define ARRAYS_LENGTH        100
 
 typedef enum {
     CODE,
diff --git a/macros.h b/macros.h
@@ -10,4 +10,6 @@
 
 #define INITIAL_SIZE        1000
 
+typedef unsigned long ulong;
+
 #endif
diff --git a/main.c b/main.c
@@ -1,5 +1,5 @@
 //    
-//    Programa escrito por Martin J. Klockner
+//    Programa escrito por Martin J. Klӧckner
 //        martin.cachari@gmail.com
 //        github.com/klewer-martin
 //
@@ -18,7 +18,8 @@
 #include "macros.h"
 #include "arguments.h"
 #include "load_country_codes.h"
-#include "readlines.h"
+#include "read_file.h"
+#include "print_file.h"
 #include "perrors.h"
 
 
@@ -32,31 +33,66 @@ int main(int argc, char * argv[])
 //    entrada y salida luego de validar que los argumentos recibidos sean correctos;
     char src[32], dest[32];
 
-//    El siguiente arreglo de dos dimensiones es donde se van a guardar los codigos
-//    de los paises;
+    FILE *fpi, *fpo;
+    ulong country, date, infected;
+    country = date = infected = 0;
+
+    prev_month = prev_country = -1;
+
+    infected_monthly = 0;
+
+//    El siguiente arreglo de dos dimensiones es donde se van a guardar los
+//    codigos    de los paises;
     char country_codes[COUNTRIES_NUMBER][ARRAYS_LENGTH];
 
 //    Valida de que los argumentos sean correctos y guarda los nombres de los
 //    archivos de entrada y salida en src y dest respectivamente, de haber algun
-//    error en el proceso devuelve un codigo de error de tipo status_t (definido 
+//    error en el proceso devuelve un codigo de error de tipo status_t (definido
 //    en main.h);
     if((st = validate_arguments(argc, argv, src, dest)) != OK) {
         print_error(st);
         return st;
     }
-
-//    Carga los codigos de error de los paises de acuerdo al standard iso3166 en el
-//    arreglo mencionado previamente 'country_codes', en caso de haber algun error 
-//    en el proceso devuelve dicho codigo e impreme por stderr un mensaje de error; 
+    
+//    Carga los codigos de error de los paises de acuerdo al standard iso3166 en
+//    el arreglo mencionado previamente 'country_codes', en caso de haber algun
+//    error en el proceso devuelve dicho codigo e impreme por stderr un mensaje
+//    de error; 
     if((st = load_country_codes(country_codes)) != OK) {
         print_error(st);
         return ERROR_LOADING_COUNTRY_CODES;    
     }
 
-    if((st = readlines(src, dest)) != OK) {
-        print_error(st);
+//    Abre el archivo de entrada en modo lectura, y el de salida en modo 
+//    escritura, si por algun motivo falla imprime un codigo de error;
+    if((fpi = fopen(src, "r")) == NULL) {
+        fclose(fpi);
+        return ERROR_READING_FILE;
+    }
+
+    if((fpo = fopen(dest, "w")) == NULL) {
+        fclose(fpo);
+        return ERROR_READING_FILE;
+    }
+
+    size_t line;
+    for(line = 0; (st = read_file(fpi, &country, &date, &infected)) == OK; line++) {
+        if(line != 0) {
+            print_file(fpo, country_codes, &country, &date, &infected);
+        }
+        st = OK;
+    }
+
+    if((st != OK) && (st != END_OF_INPUT_FILE)) {
+        fclose(fpi);
+        fclose(fpo);
         return st;
-    }    
+    }
+
+    fprintf_infected_monthly(fpo);
+
+    fclose(fpi);
+    fclose(fpo);
 
     printf(MSG_OK);
     return OK;
diff --git a/main.h b/main.h
@@ -5,11 +5,34 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <stdbool.h>
 
 #include "macros.h"
 
+
 #define COUNTRY_CODES_FILE_NAME "iso3166-1.csv"
 
+#define COUNTRIES_NUMBER    1000
+#define ARRAYS_LENGTH        100
+
+#define COUNTRY_PROMPT "Pais"
+
+#define SIZE_OF_BUFF1    32
+#define SIZE_OF_BUFF2    32    
+
+#define INITIAL_SIZE 1000
+#define TIME_MAX_DIGITS 16
+
+
+extern const char formato_de_la_fecha[];
+
+extern ulong country, date, infected;
+
+extern ulong infected_monthly;
+
+extern int prev_month, prev_country;
+
+
 typedef enum {
     OK,
     IO_FILE_NOT_FOUND,
@@ -19,8 +42,8 @@ typedef enum {
     ERROR_PRINTING,
     ERROR_READING_FILE,
     ERROR_ALLOCATING_TIME,
-    ERROR_DATA_ON_FILE_MISSING    
+    ERROR_DATA_ON_FILE_MISSING,
+    END_OF_INPUT_FILE,
 } status_t;
 
-
 #endif
diff --git a/make.bat b/make.bat
@@ -0,0 +1,12 @@
+SET CC=gcc
+SET CFLAGS=-std=c99 -Wall -pedantic
+
+
+echo %CFLAGS%
+%CC% %CFLAGS% -c print_file.c
+%CC% %CFLAGS% -c read_file.c
+%CC% %CFLAGS% -c load_country_codes.c
+%CC% %CFLAGS% -c perrors.c
+%CC% %CFLAGS% -c arguments.c
+%CC% %CFLAGS% -c main.c
+%CC% %CFLAGS% main.o arguments.o perrors.o load_country_codes.o read_file.o print_file.o -o main
diff --git a/output.txt b/output.txt
@@ -10,6 +10,22 @@ Pais: Argentina
 Fecha: 15 Jan 2020
 Infectados: 9324
 
+Infectados por mes: 16589
+-------------------------
+Pais: Argentina
+Fecha: 09 Feb 2020
+Infectados: 9324
+
+Pais: Argentina
+Fecha: 15 Feb 2020
+Infectados: 7324
+
+Pais: Argentina
+Fecha: 28 Feb 2020
+Infectados: 4324
+
+Infectados por mes: 20972
+-------------------------
 Pais: Colombia
 Fecha: 01 Jan 2020
 Infectados: 8234
@@ -22,6 +38,12 @@ Pais: Colombia
 Fecha: 15 Jan 2020
 Infectados: 9423
 
+Pais: Colombia
+Fecha: 15 Jan 2020
+Infectados: 9423
+
+Infectados por mes: 36314
+-------------------------
 Pais: Germany
 Fecha: 01 Jan 2020
 Infectados: 8432
@@ -34,3 +56,47 @@ Pais: Germany
 Fecha: 20 Jan 2020
 Infectados: 4214
 
+Infectados por mes: 21775
+-------------------------
+Pais: Germany
+Fecha: 09 Feb 2020
+Infectados: 9324
+
+Pais: Germany
+Fecha: 15 Feb 2020
+Infectados: 7324
+
+Pais: Germany
+Fecha: 28 Feb 2020
+Infectados: 4324
+
+Infectados por mes: 20972
+-------------------------
+Pais: Australia
+Fecha: 01 Jan 2020
+Infectados: 3
+
+Pais: Australia
+Fecha: 15 Jan 2020
+Infectados: 7
+
+Pais: Australia
+Fecha: 20 Jan 2020
+Infectados: 16
+
+Infectados por mes: 26
+----------------------
+Pais: Australia
+Fecha: 09 Feb 2020
+Infectados: 33
+
+Pais: Australia
+Fecha: 15 Feb 2020
+Infectados: 88
+
+Pais: Australia
+Fecha: 28 Feb 2020
+Infectados: 162
+
+Infectados por mes: 283
+-----------------------
diff --git a/print_file.c b/print_file.c
@@ -0,0 +1,115 @@
+#include "print_file.h"
+
+const char formato_de_la_fecha[] = "%d %b %Y";
+
+int prev_month, prev_country;
+ulong infected_monthly;
+
+status_t print_file(FILE *dest, char country_codes[COUNTRIES_NUMBER][ARRAYS_LENGTH], ulong *country, ulong *date, ulong *infected) {
+
+    int month;
+    char time_s[TIME_MAX_DIGITS];
+    time_translator(*(date), time_s, sizeof(time_s), "%m");
+
+    month = atoi(time_s);
+    if((prev_month == -1) || (prev_country == -1)) {
+        prev_month = month;
+        prev_country = *country;
+    }
+
+//    Imprime la suma de infectados por mes cada vez que cambia el pais;
+    if((*(country) == prev_country) && (month == prev_month)) {
+        infected_monthly += *(infected);
+    }    
+    else if(*(country) != prev_country) {
+        fprintf_infected_monthly(dest);
+        infected_monthly = *(infected);
+
+        prev_country = *(country);
+        prev_month = month;
+    }
+    else if(month != prev_month) {
+        prev_month = month;
+
+        fprintf_infected_monthly(dest);
+        infected_monthly = *(infected);
+    }
+
+//    Imprime datos segun el archivo de entrada;
+    fprintf_country(dest, *(country), country_codes);
+    fprintf_date(dest, *(date));
+    fprintf_infected(dest, *(infected), '\n');
+    
+    return OK;
+}
+
+
+status_t fprintf_country(FILE *dest, size_t country_code, char country_codes[COUNTRIES_NUMBER][ARRAYS_LENGTH])
+{
+    if((country_codes == NULL) || (dest == NULL))
+        return ERROR_NULL_POINTER;
+
+    fprintf(dest, COUNTRY_PROMPT": %s\n", country_codes[country_code]);
+    return OK;
+}
+
+status_t fprintf_date(FILE *dest, size_t date)
+{
+    char time_c[TIME_MAX_DIGITS];
+    status_t st;
+
+    if(dest == NULL)
+        return ERROR_NULL_POINTER;
+
+    if((st = time_translator(date, time_c, sizeof(time_c), formato_de_la_fecha)) != OK)
+        return st;
+
+    fprintf(dest, "Fecha: %s\n", time_c);
+    return OK;
+}
+
+status_t fprintf_infected(FILE *dest, size_t infected, char newline)
+{
+    if(dest == NULL)
+        return ERROR_NULL_POINTER;
+
+    fprintf(dest, "Infectados: %lu\n%c", infected, newline);
+    return OK;
+}
+
+
+//    Traduce de la fecha de formato unix a format y lo guarda en res como
+//    como una cadena de caracteres;
+status_t time_translator(time_t unix_time, char *res, size_t size, const char *format) 
+{
+    if(res == NULL || format == NULL)
+        return ERROR_NULL_POINTER;
+
+    
+    struct tm *tmp = gmtime(&unix_time);
+
+    if (strftime(res, size, format, tmp) == 0) {
+        (void) fprintf(stderr,  "strftime(3): cannot format supplied "
+                                "date/time into buffer of size %u "
+                                "using: '%s'\n",
+                                (unsigned int)sizeof(res), format);
+        return ERROR_ALLOCATING_TIME;
+    }
+    return OK;
+}
+
+void fprintf_infected_monthly(FILE *dest) 
+{
+    char guion_medio[] = "-----------";
+
+    int length = snprintf( NULL, 0, "%lu", infected_monthly );
+    char* str_infected_monthly = (char *)malloc( length + 1 );
+    snprintf( str_infected_monthly, length + 1, "%lu", infected_monthly );
+
+
+    fprintf(dest, "Infectados por mes: %lu\n", infected_monthly);    
+    sprintf(str_infected_monthly, "%u", 10);
+    fprintf(dest, "-------------------%.*s\n", (length + 1), guion_medio); 
+
+    free(str_infected_monthly);
+}
diff --git a/print_file.h b/print_file.h
@@ -0,0 +1,20 @@
+#ifndef PRINT_FILE_H
+#define PRINT_FILE_H
+
+#include "main.h"
+
+//extern const char formato_de_la_fecha[];
+
+status_t print_file(FILE *dest, char country_codes[COUNTRIES_NUMBER][ARRAYS_LENGTH], ulong *country, ulong *date, ulong *infected);
+
+status_t fprintf_country(FILE *dest, size_t country_code, char country_codes[COUNTRIES_NUMBER][ARRAYS_LENGTH]);
+status_t fprintf_date(FILE *dest, size_t date);
+status_t fprintf_infected(FILE *dest, size_t infected, char newline);
+
+void fprintf_infected_monthly(FILE *dest);
+
+status_t clean_buffer(char *buffer, size_t size);
+status_t time_translator(time_t unix_time, char *res, size_t size, const char *format);
+
+
+#endif
diff --git a/read_file.c b/read_file.c
@@ -0,0 +1,73 @@
+
+#include "read_file.h"
+
+
+status_t read_file(FILE *src, ulong *country, ulong *date, ulong *infected)
+{
+
+//    Esta variable es para saber de que tipo de dato estamos hablando, si es un
+//    codigo de pais, una fecha o el numero de infectados;
+    data_t data;
+
+    size_t i, j;
+//    status_t st;
+
+    char buff1[SIZE_OF_BUFF1];
+    char buff2[SIZE_OF_BUFF2];
+
+    clean_buffer(buff1, SIZE_OF_BUFF1);
+    clean_buffer(buff2, SIZE_OF_BUFF2);
+
+//    char time_s[TIME_MAX_DIGITS];
+
+//    Lee de el archivo de entrada linea por linea y va guardando las 
+//    lineas en buff1 hasta que se terminen;
+    if(fgets(buff1, sizeof(buff1), src) == NULL)
+        return END_OF_INPUT_FILE;
+    
+//    Este 'if' es para evitar la primer linea que no contiene ningun
+//    tipo de dato;
+    for(i = 0, j = 0, data = PAIS; buff1[i] != '\0'; i++)
+    {
+        if((buff1[i] == ','))
+        {
+            i++;
+            if(data == PAIS) 
+                *(country) = atoi(buff2);
+            
+            else if (data == DATE) 
+                *(date) = atol(buff2);
+            
+            data++;
+            j = 0;
+            clean_buffer(buff2, SIZE_OF_BUFF2);
+
+        } else if (buff1[i] == '\n') {
+            if(data != INFECTED) 
+                return ERROR_DATA_ON_FILE_MISSING;
+
+            data = PAIS;
+            *(infected) = atol(buff2);
+            clean_buffer(buff2, SIZE_OF_BUFF2);
+        }
+            switch(data) 
+            {
+                case PAIS: buff2[i] = buff1[i];    break;
+                case DATE: buff2[j] = buff1[i]; j++; break;
+                case INFECTED: buff2[j] = buff1[i]; j++; break;
+            }
+    }
+    return OK;
+}
+
+status_t clean_buffer(char *buffer, size_t size)
+{
+    if(buffer == NULL)
+        return ERROR_NULL_POINTER;
+
+    size_t i;
+    for(i = 0; i < size; i++)
+        buffer[i] = '\0';
+    
+    return OK;
+}
diff --git a/read_file.h b/read_file.h
@@ -0,0 +1,21 @@
+#ifndef READLINES_H
+#define READLINES_H
+
+#include "main.h"
+#include "load_country_codes.h"
+
+typedef enum {
+    PAIS,
+    DATE,
+    INFECTED
+} data_t;
+
+status_t read_file(FILE *src, ulong *country, ulong *date, ulong *infected);
+
+status_t fprintf_date(FILE *dest, size_t data);
+status_t fprintf_infected(FILE *dest, size_t data, char newline);
+status_t clean_buffer(char *buffer, size_t size);
+status_t time_translator(time_t unix_time, char *res, size_t size, const char *format); 
+status_t fprintf_country(FILE *dest, size_t country_code, char country_codes[COUNTRIES_NUMBER][ARRAYS_LENGTH]);
+
+#endif
diff --git a/readlines.c b/readlines.c
@@ -1,189 +0,0 @@
-//    Lee el archivo de entrada y va separando los datos mientras va leyendo linea
-//    por linea, y los va imprimiendo en pantalla
-
-#include "readlines.h"
-
-const char formato_de_la_fecha[] = "%d %b %Y";
-
-status_t readlines(char *src, char *dest)
-{
-    size_t line, i, j;
-    status_t st;
-
-//    Puntero para el archivo de entrada y de salida respectivamente;    
-    FILE *fpi; 
-    FILE *fpo;
-
-
-    char buff1[SIZE_OF_BUFF1];
-    char buff2[SIZE_OF_BUFF2];
-
-    clean_buffer(buff1, SIZE_OF_BUFF1);
-    clean_buffer(buff2, SIZE_OF_BUFF2);
-
-//    Esta variable es para saber de que tipo de dato estamos hablando, si es un
-//    codigo de pais, una fecha o el numero de infectados;
-    data_t data;
-
-    unsigned long country;
-    unsigned long date;
-    unsigned long infected;
-
-//    Arreglo para almacenar los codigos de los paises segun el standard iso3166-1,
-    char country_codes[COUNTRIES_NUMBER][ARRAYS_LENGTH];
-
-//    Carga los datos al arreglo mencionado previamente, en caso de haber algun
-//    error devuelve el codigo de dicho error;
-    if((st = load_country_codes(country_codes)) != OK) 
-        return st;
-    
-//    Abre el archivo de entrada en modo lectura si por algun motivo no se puede
-//    abrir devuelve un codigo de error;
-    if((fpi = fopen(src, "r")) == NULL)
-            return ERROR_READING_FILE;
-
-    if((fpo = fopen(dest, "w")) == NULL)
-            return ERROR_READING_FILE;
-
-//    Lee de el archivo de entrada linea por linea y va guardando las 
-//    lineas en buff1 hasta que se terminen;
-    for(line = 0; fgets(buff1, sizeof(buff1), fpi) != NULL; line++)
-    {
-//    Este 'if' es para evitar la primer linea que no contiene ningun tipo de dato;
-        if(line != 0) {
-//            Recorre el buff1 separando los datos de acuerdo a si es el codigo de
-//            un pais, una fecha o el numero de infectados;
-            for(i = 0, j = 0, data = PAIS; buff1[i] != '\0'; i++)
-            {
-
-//                Si encuentra una coma cambia el tipo de dato;
-                if((buff1[i] == ','))
-                {
-//                    Saltea la coma;                    
-                    i++;
-
-//                    De acuerdo al tipo de dato que se guardo hasta llegar a la
-//                    coma va a guardarlo de distinta manera, ej: si el dato que
-//                    se guardo en buff2 era el codigo de un PAIS, entonces lo 
-//                    guarda en la variable country, si el tipo de dato que se 
-//                    guardo en buff2 era una fecha entonces lo guarda en date, etc;
-                    switch(data) 
-                    {
-                        case PAIS: country = atoi(buff2); break;
-                        case DATE: date = atol(buff2); j++; break;
-                    }
-
-
-//                    Como encontro una coma entonces el tipo de dato cambia;
-                    data++;
-
-//                    j vale cero porque es el indice de el buffer en el que se van
-//                    guardando los datos;
-                    j = 0;
-
-//                    Se limpia el buffer ya que se va a volver a utilizar;
-                    clean_buffer(buff2, SIZE_OF_BUFF2);
-
-
-//                Si en lugar de una coma se encuentra un caracter de nueva line 
-//                entonces significa que esta parado en el ultimo dato
-                } else if (buff1[i] == '\n') {
-
-//                    Si estamos parados en el ultimo dato y no es INFECTED,
-//                    entonces la variable datos no se incremento tres veces, por
-//                    lo cual se supone que falta un dato, devolviendo un codigo de
-//                    error;
-                    if(data != INFECTED) 
-                        return ERROR_DATA_ON_FILE_MISSING;
-
-//                    Si esta todo bien entonces el dato vuelve a ser PAIS que es 
-//                    el primer dato de el archivo de entrada
-                    data = PAIS;
-                    infected = atol(buff2);
-                    clean_buffer(buff2, SIZE_OF_BUFF2);
-                }
-
-                switch(data) 
-                {
-                    case PAIS: buff2[i] = buff1[i];    break;
-                    case DATE: buff2[j] = buff1[i]; j++; break;
-                    case INFECTED: buff2[j] = buff1[i]; j++; break;
-                }
-            }
-            fprintf_country(fpo, country, country_codes);
-            fprintf_date(fpo, date);
-            fprintf_infected(fpo, infected);
-        }
-    }
-
-    fclose(fpi);
-    fclose(fpo);
-    return OK;
-}
-
-
-
-status_t fprintf_country(FILE *dest, size_t country_code, char country_codes[COUNTRIES_NUMBER][ARRAYS_LENGTH])
-{
-    if((country_codes == NULL) || (dest == NULL))
-        return ERROR_NULL_POINTER;
-
-    fprintf(dest, COUNTRY_PROMPT": %s\n", country_codes[country_code]);
-    return OK;
-}
-
-status_t fprintf_date(FILE *dest, size_t date)
-{
-    char time_c[TIME_MAX_DIGITS];
-    status_t st;
-
-    if(dest == NULL)
-        return ERROR_NULL_POINTER;
-
-    if((st = time_translator(date, time_c, sizeof(time_c))) != OK)
-        return st;
-
-    fprintf(dest, "Fecha: %s\n", time_c);
-    return OK;
-}
-
-status_t fprintf_infected(FILE *dest, size_t infected)
-{
-    if(dest == NULL)
-        return ERROR_NULL_POINTER;
-
-    fprintf(dest, "Infectados: %lu\n\n", infected);
-    return OK;
-}
-
-status_t clean_buffer(char *buffer, size_t size)
-{
-    if(buffer == NULL)
-        return ERROR_NULL_POINTER;
-
-    size_t i;
-    for(i = 0; i < size; i++)
-        buffer[i] = '\0';
-    
-    return OK;
-}
-
-
-status_t time_translator(time_t unix_time, char *res, size_t size) 
-{
-    if(res == NULL)
-        return ERROR_NULL_POINTER;
-
-    const char *format = formato_de_la_fecha;
-    struct tm *tmp = gmtime(&unix_time);
-
-    if (strftime(res, size, format, tmp) == 0) {
-        (void) fprintf(stderr,  "strftime(3): cannot format supplied "
-                                "date/time into buffer of size %u "
-                                "using: '%s'\n",
-                                (unsigned int)sizeof(res), format);
-        return ERROR_ALLOCATING_TIME;
-    }
-    return OK;
-}
-
diff --git a/readlines.h b/readlines.h
@@ -1,30 +0,0 @@
-#ifndef READLINES_H
-#define READLINES_H
-
-#include "main.h"
-#include "load_country_codes.h"
-
-#define COUNTRY_PROMPT "Pais"
-
-#define SIZE_OF_BUFF1    32
-#define SIZE_OF_BUFF2    32    
-
-#define INITIAL_SIZE 1000
-#define TIME_MAX_DIGITS 1000
-
-extern const char formato_de_la_fecha[];
-
-typedef enum {
-    PAIS,
-    DATE,
-    INFECTED
-} data_t;
-
-status_t readlines(char *src, char *dest);
-status_t fprintf_date(FILE *dest, size_t data);
-status_t fprintf_infected(FILE *dest, size_t data);
-status_t clean_buffer(char *buffer, size_t size);
-status_t time_translator(time_t unix_time, char *res, size_t size); 
-status_t fprintf_country(FILE *dest, size_t country_code, char country_codes[COUNTRIES_NUMBER][ARRAYS_LENGTH]);
-
-#endif