SimpCSV is a simple and lightweight CSV parsing library designed for random access, written in C.
This library does not check if:
- The CSV file exists.
- The CSV file is properly formatted.
- You have enough memory to parse the CSV file.
Any segmentation faults that occur are probably the result of the above.
#include <stdio.h>
#include "simpcsv.h"
int main(void)
{
SimpCSVHandle* handle = simpcsv_open_file("test.csv", '"', ',', '\n');
simpcsv_count_rows_and_cols(handle);
for (size_t ri = 0; ri < handle->m_number_of_rows; ri++)
{
for (size_t ci = 0; ci < handle->m_number_of_cols; ci++)
{
// do something...
}
}
simpcsv_close_file(handle);
return 0;
}To use the library, add the header and source file into your repository, and adjust your build configuration accordingly.
Every single function is annotated with comments in both the header file and the source file.
The comments in the header file contain a quick brief of what each function does. The comments in the source file contain more detailed documentation of the function's parameters and return value.
The quick example at the top under "Example" also shows you the general layout of a program using SimpCSV and how to iterate through all the cells in a CSV file.
Currently, this project has been developed and tested on Linux (Arch) machines only.
Feel free to contribute to the project and improve it. There are no strict rules regarding contribution.
The project is available under the MIT license.
Copyright (C) David Filiks