Skip to content

Commit bf24c2d

Browse files
author
Vyacheslav Brover
committed
TextTable(,,headerP,)
1 parent 6bacbfe commit bf24c2d

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

tsv/tsv.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ void TextTable::Header::qc () const
133133

134134
TextTable::TextTable (const string &tableFName,
135135
const string &columnSynonymsFName,
136+
bool headerP,
136137
uint displayPeriod)
137138
: Named (tableFName)
138139
{
@@ -163,10 +164,21 @@ TextTable::TextTable (const string &tableFName,
163164
header << std::move (Header (std::move (s)));
164165
}
165166
ASSERT (! header. empty ());
166-
if (! thisPound)
167+
if (headerP)
167168
{
168-
if (! pound)
169-
dataExists = f. nextLine ();
169+
if (! thisPound)
170+
{
171+
if (! pound)
172+
dataExists = f. nextLine ();
173+
break;
174+
}
175+
}
176+
else
177+
{
178+
FFOR (size_t, i, header. size ())
179+
header [i]. name = to_string (i + 1);
180+
dataExists = true;
181+
pound = true;
170182
break;
171183
}
172184
}
@@ -649,13 +661,7 @@ void TextTable::merge (RowNum toRowNum,
649661
if (to [i]. empty ())
650662
to [i] = from [i];
651663
else
652-
{
653-
StringVector vec (to [i], aggr_sep, true);
654-
vec << from [i];
655-
vec. sort ();
656-
vec. uniq ();
657-
to [i] = vec. toString (string (1, aggr_sep));
658-
}
664+
aggregate (to [i], from [i], aggr_sep);
659665
}
660666
}
661667

tsv/tsv.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ struct TextTable : Named
193193

194194
explicit TextTable (const string &tableFName,
195195
const string &columnSynonymsFName = noString,
196+
bool headerP = true,
196197
uint displayPeriod = 0);
197198
// Input: tableFName: format: [{'#' <comment> <EOL>}* '#'] <header> <EOL> {<row> <EOL>>}*
198199
// empty lines are skipped

0 commit comments

Comments
 (0)