GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing cpp.libhunt.com — Rapidcsv Alternatives - C++ CSV | LibHunt RapidcsvC++ CSV parser library
Take the C++ Developer Survey
- About 6 minutes on the tools, libraries and AI you use with C++. You get the results by email.
Take the survey »
Popularity
5.5
Growing
Activity
6.1
-
Stars
1,082
Watchers
21
Forks
202
Last Commit
DescriptionRapidcsv is a C++ header-only library for CSV parsing. While the name admittedly was inspired by the rapidjson project, the objectives are not the same. The goal of rapidcsv is to be an easy-to-use CSV library enabling rapid development. For optimal performance (be it CPU or memory usage) a CSV parser implemented for the specific use-case is likely to be more performant.
Programming language: C++
License: BSD 3-clause "New" or "Revised" License
Latest version: v8.99
Rapidcsv alternatives and similar libraries
Based on the "CSV" category.
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
Promo
www.saashub.com
Do you think we are missing an alternative of Rapidcsv or a related project? READMERapidcsv
Rapidcsv is an easy-to-use C++ CSV parser library. It supports C++11 (and later), is header-only and comes with a basic test suite. The library was featured in the book C++20 for Programmers. Example UsageHere is a simple example reading a CSV file and getting 'Close' column as a vector of floats. [colhdr.csv](examples/colhdr.csv) content:
[ex001.cpp](examples/ex001.cpp) content:
Refer to section More Examples below for more examples. The [tests](tests/) directory also contains many simple usage examples. Supported PlatformsRapidcsv is implemented using C++11 with the intention of being portable. It's been tested on:
InstallationSimply copy src/rapidcsv.h to your project/include directory and include it. More ExamplesSeveral of the following examples are also provided in the
Reading a File with Column and Row HeadersBy default rapidcsv treats the first row as column headers, and the first column is treated as data. This allows accessing columns using their labels, but not rows or cells (only using indices). In order to treat the first column as row headers one needs to use LabelParams and set pRowNameIdx to 0. Column and Row Headers[colrowhdr.csv](examples/colrowhdr.csv) content:
[ex002.cpp](examples/ex002.cpp) content:
Row Headers Only[rowhdr.csv](examples/rowhdr.csv) content:
[ex003.cpp](examples/ex003.cpp) content:
No Headers[nohdr.csv](examples/nohdr.csv) content:
[ex004.cpp](examples/ex004.cpp) content:
Reading a File with Custom SeparatorFor reading of files with custom separator (i.e. not comma), one need to specify the SeparatorParams argument. The following example reads a file using semi-colon as separator. [semi.csv](examples/semi.csv) content:
[ex005.cpp](examples/ex005.cpp) content:
Supported Get/Set Data TypesThe internal cell representation in the Document class is using std::string
and when other types are requested, standard conversion routines are used.
All standard conversions are relatively straight-forward, with the
exception of [colrowhdr.csv](examples/colrowhdr.csv) content:
[ex006.cpp](examples/ex006.cpp) content:
Global Custom Data Type ConversionOne may override conversion routines (or add new ones) by implementing ToVal() and/or ToStr(). Below is an example overriding int conversion, to instead provide two decimal fixed-point numbers. Also see tests/test035.cpp for a test overriding ToVal() and ToStr(). [ex008.cpp](examples/ex008.cpp) content:
Custom Data Type Conversion Per CallIt is also possible to override conversions on a per-call basis, enabling more flexibility. This is illustrated in the following example. Additional conversion override usage can be found in the test tests/test063.cpp [ex009.cpp](examples/ex009.cpp) content:
Reading CSV Data from a Stream or StringIn addition to specifying a filename, rapidcsv supports constructing a Document
from a stream and, indirectly through stringstream, from a string. File streams
used with rapidcsv should be opened in [ex007.cpp](examples/ex007.cpp) content:
Reading a File with Invalid Numbers (e.g. Empty Cells) as Numeric DataBy default rapidcsv throws an exception if one tries to access non-numeric data as a numeric data type, as it basically propagates the underlying conversion routines' exceptions to the calling application. The reason for this is to ensure data correctness. If one wants to be able to read data with invalid numbers as numeric data types, one can use ConverterParams to configure the converter to default to a numeric value. The value is configurable and by default it's std::numeric_limits::signaling_NaN() for float types, and 0 for integer types. Example:
Check if a Column ExistsRapidcsv provides the methods GetColumnNames() and GetRowNames() to retrieve the column and row names. To check whether a particular column name exists one can for example do:
Handling Quoted CellsBy default rapidcsv automatically dequotes quoted cells (i.e. removes the encapsulating
Skipping Empty and Comment LinesRapidcsv reads all lines by default, but may be called to ignore comment lines starting with a specific character, example:
Using LineReaderParams it is also possible to skip empty lines, example:
UTF-16 and UTF-8Rapidcsv's preferred encoding for non-ASCII text is UTF-8. UTF-16 LE and UTF-16 BE can be read and written by rapidcsv on systems where codecvt header is present. Define HAS_CODECVT before including rapidcsv.h in order to enable the functionality. Rapidcsv unit tests automatically detects the presence of codecvt and sets HAS_CODECVT as needed, see [CMakeLists.txt](CMakeLists.txt) for reference. When enabled, the UTF-16 encoding of any loaded file is automatically detected. CMake FetchContentRapidcsv may be included in a CMake project using FetchContent. Refer to the [CMake FetchContent Example Project](examples/cmake-fetchcontent) and in particular its [CMakeLists.txt](examples/cmake-fetchcontent/CMakeLists.txt). Locale Independent ParsingRapidcsv uses locale-dependent conversion functions when parsing float values
by default. It is possible to configure rapidcsv to use locale independent
parsing by setting API DocumentationThe following classes makes up the Rapidcsv interface:
Technical DetailsRapidcsv uses cmake for its tests. Commands to build and execute the test suite:
Rapidcsv uses doxygenmd to generate its Markdown API documentation:
Rapidcsv uses Uncrustify to ensure consistent code formatting:
AlternativesThere are many CSV parsers for C++, for example: LicenseRapidcsv is distributed under the BSD 3-Clause license. See LICENSE file. ContributionsBugs, PRs, etc are welcome on the GitHub project page https://github.com/d99kris/rapidcsv Keywordsc++, c++11, csv parser, comma separated values, single header library.
Do not miss the trending, libraries, news and articles with our weekly report.
Spin The Wheel Of Names
for a cryptographically secure random name picker.
Schedule a when to meet poll. | ||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |