Repository: conan-io/conan-center-index

Issue:
[request] csv-parser/2.1.0
### Package Details
  * Package Name/Version: **csv-parser/2.1.0**
  * Website: **https://cmake.org/**
  * Source code: **https://github.com/vincentlaucsb/csv-parser**


### Description Of The Library / Tool
A modern C++ library for reading, writing, and analyzing CSV (and similar) files. 


Discussion:

Resolving patch:
diff --git a/recipes/vincentlaucsb-csv-parser/all/conanfile.py b/recipes/vincentlaucsb-csv-parser/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/vincentlaucsb-csv-parser/all/conanfile.py
@@ -0,0 +1,43 @@
+from conans import ConanFile, tools
+from conans.errors import ConanInvalidConfiguration
+import os
+
+required_conan_version = ">=1.33.0"
+
+
+class VincentlaucsbCsvParserConan(ConanFile):
+    name = "vincentlaucsb-csv-parser"
+    description = "Vince's CSV Parser with simple and intuitive syntax"
+    topics = ("conan", "csv-parser", "csv", "rfc 4180", "parser", "generator")
+    url = "https://github.com/conan-io/conan-center-index"
+    homepage = "https://github.com/vincentlaucsb/csv-parser"
+    license = "MIT"
+    settings = "os", "compiler"
+    no_copy_source = True
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    def validate(self):
+        if self.settings.compiler.cppstd:
+            tools.check_min_cppstd(self, 11)
+
+        compiler = self.settings.compiler
+        compiler_version = tools.Version(self.settings.compiler.version)
+        if compiler == "gcc" and compiler_version < "7":
+            raise ConanInvalidConfiguration("gcc version < 7 not supported")
+
+    def package_id(self):
+        self.info.header_only()
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)
+
+    def package(self):
+        self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
+        self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "single_include"))
+
+    def package_info(self):
+        if self.settings.os in ("Linux", "FreeBSD"):
+            self.cpp_info.system_libs.append("pthread")


Test patch:
diff --git a/recipes/vincentlaucsb-csv-parser/all/test_package/CMakeLists.txt b/recipes/vincentlaucsb-csv-parser/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/vincentlaucsb-csv-parser/all/test_package/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.9)
+project(test_package)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup()
+
+add_executable(${PROJECT_NAME} test_package.cpp)
+target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
diff --git a/recipes/vincentlaucsb-csv-parser/all/test_package/conanfile.py b/recipes/vincentlaucsb-csv-parser/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/vincentlaucsb-csv-parser/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+from conans import ConanFile, CMake, tools
+import os
+
+
+class TestPackageConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        if not tools.cross_building(self.settings):
+            bin_path = os.path.join("bin", "test_package")
+            self.run(bin_path, run_environment=True)
diff --git a/recipes/vincentlaucsb-csv-parser/all/test_package/test_package.cpp b/recipes/vincentlaucsb-csv-parser/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/vincentlaucsb-csv-parser/all/test_package/test_package.cpp
@@ -0,0 +1,25 @@
+#include "csv.hpp"
+
+#include <sstream>
+#include <iostream>
+
+int main() {
+    using namespace csv;
+    std::stringstream rows("A,B,C\n"
+                           "1,2,3\n"
+                           "4,5,6");
+
+    CSVReader reader(rows);
+
+    std::vector<std::string> col_names = reader.get_col_names();
+    for (auto name : col_names)
+        std::cout << name << ", ";
+
+    CSVRow row;
+    if (reader.read_row(row)){
+        for (auto& field : row)
+            std::cout << std::string(field) << ", ";
+    }
+
+    return 0;
+}