Skip to content
fleschutzPublic

Latest commit

 

History

302 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSV2HPP Converter

Convert the content of a .CSV file (comma-separated values) into a header file for C/C++ software projects with this command-line utility. Then #include the new header file and immediately start to develop on a structured, well-formed dataset (and skip error-prone steps like file delivering, loading, parsing, converting, and checking).

▶️ Usage

  1. Export or download your database in CSV format, e.g. bucket_list.csv
  2. Open the CSV file in a text editor and add datatype hints in parentheses to the header line, e.g.:
    Location (std::string), Latitude (double), Longitude (double)
  3. Execute in a terminal window: csv2hpp bucket_list.csv POI > bucket_list.hpp
  4. Copy the new header file (e.g. bucket_list.hpp) into your project and #include it.

💡 Hints

  • Build it by executing: cd src && cmake . && make (just requires cmake and a C++ compiler)
  • Datatype hints are mapped to C/C++ datatypes as follows: (std::string) → std::string, (double) → double, and so on ((skip) skips the column). All 98 supported datatype hints are listed in: datatype_hints.csv
  • Empty CSV data cells are mapped to "" for strings and to 00 for everything else (as a hint).
  • Precision hints such as '±05' are removed in float or double values (not supported in C/C++).
  • Supports huge .CSV files by omitting whitespaces and removing trailing 0's. It's also recommended to use 'const char*' instead of 'std::string' which can break some compilers.
  • See the 📁examples subfolder for many sample conversions.

🤝 Contributing

  • Contributions, suggestions, and improvements are welcome!
  • Open an Issue if you encounter bugs or have feature ideas.
  • Create a Pull Request if you'd like to improve something.

📜 License & Copyright

This open source project is licensed under the CC0-1.0 license. All trademarks are the property of their respective owners.

Releases

Packages

Contributors

Languages