示例#1
0
Lista *Arquivo::lerArquivo(){

    string paciente1;
    string espaco;
    Lista *lista = new Lista;
    ifstream arquivo("/home/haliski/Downloads/TrabalhoAlzeimer-master/Pacientes.csv");

    if(!arquivo.is_open()){
        cout << "arquivo nao foi aberto!\n";
        return NULL;
    }

    //getline(arquivo,paciente1);
    while(!arquivo.eof()){
        Paciente *paciente = new Paciente;

        getline(arquivo,paciente1,';');
        paciente->setNome(paciente1.c_str());
        getline(arquivo,paciente1,';');
        paciente->setIdade(atoi(paciente1.c_str()));
        getline(arquivo,paciente1,';');
        paciente->setContinente(paciente1.c_str());
        getline(arquivo,paciente1,';');
        paciente->setSexo(paciente1.c_str());
        getline(arquivo,paciente1,';');
        paciente->setHistorico(paciente1.c_str());
        getline(arquivo,paciente1,'\r');
        paciente->setTratamento(paciente1.c_str());

        lista->inserir(paciente);
    }
    return lista;
}
示例#2
0
ListaPaciente *Arquivo::lerArquivo(){

    string paciente1;
    string espaco;
    ListaPaciente *lista = new ListaPaciente;
    ifstream arquivo("/home/igor/SistemaAlzeimer/Pacientes.csv");
    Tratamento tratamento;
    if(!arquivo.is_open()){
        cout << "arquivo nao foi aberto!\n";
        return NULL;
    }
    string teste;
    getline(arquivo,teste,char(13));
    while(!arquivo.eof()){
        Paciente *paciente = new Paciente;

        getline(arquivo,paciente1,';');
        paciente->setNome(paciente1.c_str());
        getline(arquivo,paciente1,';');
        paciente->setIdade(atoi(paciente1.c_str()));
        getline(arquivo,paciente1,';');
        paciente->setContinente(paciente1.c_str());
        getline(arquivo,paciente1,';');
        paciente->setSexo(paciente1.c_str());
        getline(arquivo,paciente1,';');
        paciente->setHistorico(paciente1.c_str());
        getline(arquivo,paciente1,'\r');
        tratamento.setNome(paciente1.c_str());
        paciente->setTratamento(tratamento);
        lista->inserir(paciente);
    }
    return lista;
}