How can I read a CSV file with different line types?

0

I'm trying to read a CSV file that has different rows. I'm using fgets and strtok to save to a list. the problem is that being different rows I do not know how to stop and move on to the next one.

typedef struct{
int id_viagem;
int duracao;
int mes_init;
int dia_init;
int ano_init;
int hora_init;
int min_init;
int id_estacao_init;
int mes_final;
int dia_final;
int ano_final;
int min_final;
int id_estacao_final;
char *bicicleta;
int tipo; 
int nascimento;
char *genero;
}INFO_VIAGEM;

This is the structure that originates the list, and these are the different line types:

41,460.7 / 28/2011 12: 10: 00,22,7 / 28/2011 12: 18: 00,49, B00353, Registered, 1972, Male

61,1315.7 / 28/2011 12: 33: 00,36,7 / 28/2011 12:55: 00,38, B00228, Casual ,

auxx=strtok(NULL, str_div);
    tipo=auxx;
    if(strcmp(tipo, "Casual") == 0){
        z.tipo=0;

    }
    else{
        z.tipo=1;
        auxx=strtok(NULL, str_div);
        z.nascimento=atoi(auxx);

        auxx=strtok(NULL, str_div3);
        z.genero=auxx;
    }

Just like the first line and always registered it always reads what there is not. How can I do it?

    
asked by anonymous 25.05.2017 / 00:18

0 answers