Skip to content

Commit

Permalink
only add ageGroup column if not present in table
Browse files Browse the repository at this point in the history
  • Loading branch information
simei94 committed Feb 11, 2025
1 parent 7ad5d7a commit d56b5f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/org/matsim/run/analysis/PtLineAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,10 @@ private void writeAgeDistr(Table persons, String outputString) {
labels.put(ageGroups.getLast() + "+", Range.of(ageGroups.getLast(), 120));
ageGroups.add(Integer.MAX_VALUE);

persons.addColumns(StringColumn.create(AGE_GROUP));
// only add ageGroup column if not present
Optional.of(AGE_GROUP)
.filter(col -> !persons.columnNames().contains(col))
.ifPresent(col -> persons.addColumns(StringColumn.create(col)));

for (int i = 0; i < persons.rowCount(); i++) {
Row row = persons.row(i);
Expand Down

0 comments on commit d56b5f6

Please sign in to comment.