Commit 5975816259923bacdf7ccc11a8560176648e1570

Authored by Jürgen Knödlseder
1 parent d8b4579b

GCsv interprets lines in CSV files starting with # as comment lines (#2291)

ChangeLog
1   -2018-01-22
  1 +2018-01-23
2 2  
3 3 * Version 1.5.0 released
4 4 =========================
... ... @@ -8,9 +8,11 @@
8 8 Non-point source model throws exception in On/Off fitting (#2296)
9 9 Set reference time to CTA reference time in GCTAEventcube, GCTAEventList and
10 10 GCTACubeExposure (#2295)
  11 + GCsv interprets lines in CSV files starting with # as comment lines (#2291)
11 12 Add GPha::counts_spectrum() and GPha::backscal_spectrum() methods (#2290)
12 13 Add GNdarray sign(), operator*= and operator/= (#2290)
13   - Add GSkyMap::counts() and GSkyMap::flux() methods and clip() friend operator (#2290)
  14 + Add GSkyMap::counts() and GSkyMap::flux() methods and clip() friend operator
  15 + (#2290)
14 16 Add GSkyMap::array() method to Python interface (#2285)
15 17 Add Off sky regions to GCTAObservation (#2284)
16 18 By default require cfitsio library (#2265)
... ...
1 1 New Features and Important Changes in GammaLib 1.5.0
2 2  
3   -22 January 2018
  3 +23 January 2018
4 4  
5 5  
6 6 1. Introduction
... ... @@ -199,7 +199,7 @@ a FITS file map. All positive pixels will define the region (#1121).
199 199  
200 200 13. Support module
201 201 ------------------
202   -None
  202 +The GCsv class now accepts lines staring with # as comment lines (#2291).
203 203  
204 204  
205 205 14. XML module
... ...
doc/source/admin/release_history/1.5.rst
... ... @@ -37,6 +37,8 @@ Improvements
37 37 * [`2295 <https://cta-redmine.irap.omp.eu/issues/2295>`_] -
38 38 Set reference time to CTA reference time in ``GCTAEventcube``, ``GCTAEventList``
39 39 and ``GCTACubeExposure``
  40 +* [`2291 <https://cta-redmine.irap.omp.eu/issues/2291>`_] -
  41 + ``GCsv`` interprets lines in CSV files starting with # as comment lines
40 42 * [`2290 <https://cta-redmine.irap.omp.eu/issues/2290>`_] -
41 43 Add ``GSkyMap::counts()`` and ``GSkyMap::flux()`` methods and ``clip()``
42 44 friend operator, ``GNdarray`` ``sign()``, ``operator*=`` and ``operator/=``,
... ...
src/support/GCsv.cpp
1 1 /***************************************************************************
2 2 * GCsv.cpp - Comma-separated values table class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2016 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -441,13 +441,18 @@ void GCsv::load(const GFilename&amp; filename, const std::string&amp; sep)
441 441  
442 442 // Get line with leading and trailing whitespace removed
443 443 std::string sline =
444   - gammalib::strip_chars(gammalib::strip_whitespace(std::string(line)),"\n");
  444 + gammalib::strip_chars(gammalib::strip_whitespace(std::string(line)),"\n");
445 445  
446   - // Skip line if empty
  446 + // Skip empty lines
447 447 if (sline.length() == 0) {
448 448 continue;
449 449 }
450 450  
  451 + // Skip lines starting with a hash as those are comment lines
  452 + if (sline[0] == '#') {
  453 + continue;
  454 + }
  455 +
451 456 // Split line in elements
452 457 std::vector<std::string> elements = gammalib::split(sline, sep);
453 458 for (int i = 0; i < elements.size(); ++i) {
... ...
test/data/csv.dat
1 1 ra,dec,duration
2 2 10.0,-12.0,1800.0
3 3 12.0,-10.0,1000.0
  4 +# This is a comment line
4 5 14.0,-8.0,100.0
5 6  
... ...