csv.cc 1.45 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* Spell-QTL  Software suite for the QTL analysis of modern datasets.
 * Copyright (C) 2016,2017  Damien Leroux <damien.leroux@inra.fr>, Sylvain Jasson <sylvain.jasson@inra.fr>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

18
#include "error.h"
Damien Leroux's avatar
Damien Leroux committed
19
20
21
22
#include "pedigree.h"


std::vector<pedigree_item>
23
read_csv(const std::string& pedigree_file, char field_sep)
Damien Leroux's avatar
Damien Leroux committed
24
25
{
    std::vector<pedigree_item> ret;
26
    ifile pef(pedigree_file);
Damien Leroux's avatar
Damien Leroux committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
    if (!pef.good()) {
        MSG_DEBUG("prout");
    }
    std::string col_name, col_id, col_p1, col_p2;
    read_csv_line(pef, field_sep, col_name, col_id, col_p1, col_p2);
    /*MSG_DEBUG("col_name=" << col_name << " col_id=" << col_id << " col_p1=" << col_p1 << " col_p2=" << col_p2);*/
    while (!pef.eof()) {
        ret.emplace_back(pef, field_sep);
        if (ret.back().id == 0) {
            ret.pop_back();
        }
    }
    return ret;
}