MCPcopy Create free account
hub / github.com/BirolLab/abyss / createCSV

Function createCSV

DataBase/db-csv.cc:41–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40template <typename D>
41static string createCSV(
42 D& db, const string& t, const string& csv)
43{
44 ofstream csvf(csv.c_str());
45 stringstream ps, ss, msg;
46 string pstr, sstr;
47 dbVec head, val;
48
49 ps << "pragma table_info (" << t << ");";
50 pstr = ps.str();
51 head = db.readSqlToVec(pstr.c_str());
52
53 for (unsigned i=0; i<head.size(); i++)
54 csvf << head[i][1] << ((i == (head.size()-1)) ? "" : ",");
55 csvf << endl;
56
57 ss << "select * from " << t << ";";
58 sstr = ss.str();
59 val = db.readSqlToVec(sstr.c_str());
60
61 for (unsigned i=0; i<val.size(); i++) {
62 for (unsigned j=0; j<val[i].size(); j++)
63 csvf << val[i][j] << ((j == (val[i].size()-1)) ? "" : ",");
64 csvf << endl;
65 }
66 msg << csv << " has been created.\n";
67 return msg.str();
68}
69
70template <typename D>
71static void populateOneTable(

Callers 1

populateOneTableFunction · 0.85

Calls 4

readSqlToVecMethod · 0.80
c_strMethod · 0.45
strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected