OpenMS
CsvFile.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: David Wojnar $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/FORMAT/TextFile.h>
13 
14 namespace OpenMS
15 {
23  class OPENMS_DLLAPI CsvFile :
24  private TextFile
25  {
26 public:
27 
30 
32  ~CsvFile() override;
33 
44  CsvFile(const String& filename, char is = ',', bool ie = false, Int first_n = -1);
45 
56  void load(const String& filename, char is = ',', bool ie = false, Int first_n = -1);
57 
63  void store(const String& filename);
64 
70  void addRow(const StringList& list);
71 
77  void clear();
78 
89  bool getRow(Size row, StringList& list) const;
90 
96  std::vector<String>::size_type rowCount() const;
97 
98 private:
101 
102  };
103 
104 } // namespace OpenMS
105 
This class handles csv files. Currently only loading is implemented. Does NOT support comment lines!
Definition: CsvFile.h:25
std::vector< String >::size_type rowCount() const
Returns the number of rows that were loaded from the file.
bool getRow(Size row, StringList &list) const
writes all items from a row to list
void store(const String &filename)
Stores the buffer's content into a file.
bool itemenclosed_
Definition: CsvFile.h:100
void addRow(const StringList &list)
Add a row to the buffer.
CsvFile(const String &filename, char is=',', bool ie=false, Int first_n=-1)
Constructor with filename.
CsvFile()
Default constructor.
char itemseperator_
Definition: CsvFile.h:99
void clear()
Clears the buffer.
void load(const String &filename, char is=',', bool ie=false, Int first_n=-1)
Loads data from a text file.
~CsvFile() override
destructor
A more convenient string class.
Definition: String.h:34
Definition: TextFile.h:21
int Int
Signed integer type.
Definition: Types.h:72
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19