CSV parser library in C.
Appendix
This is a C library that provides simple functions to parse CSV data, manipulate CSV rows, and handle common CSV errors. Whether you need to read CSV files, generate CSV strings, or work with CSV data in your C application.
Features
- Parse CSV data from files or strings
- Create and manipulate CSV rows
- Write CSV data to files or strings
- Retrieve CSV field values by index
- Handle common CSV errors with ease
Tech Stack
Languages: C
Build: Make and Docker
Installation
Clone the project
git clone https://codeberg.org/luizvilasboas/libcsv.git
Go to the project directory
Compile the library
Install the library
Usage/Examples
#include <stdio.h>
int main() {
if (!parser) {
fprintf(stderr, "Error: Unable to create CSV parser\n");
return 1;
}
}
}
return 0;
}
char * csv_get_field(const CSVRow *row, int field_index)
Retrieves the value of a specific field in a row by its index.
Definition libcsv.c:246
CSVRow * csv_read_row(CSVParser *parser)
Reads the next row from the CSV file using the parser.
Definition libcsv.c:46
void csv_parser_destroy(CSVParser *parser)
Frees resources associated with the parser and closes the open file.
Definition libcsv.c:32
void csv_row_destroy(CSVRow *row)
Frees memory allocated for a CSVRow structure and all its internal fields.
Definition libcsv.c:146
CSVParser * csv_parser_create(const char *filename, char delimiter)
Creates and initializes a parser to read a CSV file.
Definition libcsv.c:11
Structure managing the state of a CSV file parser.
Definition libcsv.h:27
Structure representing a single CSV row.
Definition libcsv.h:19
int field_count
Definition libcsv.h:21
Documentation
"" "Documentation"
Running Tests
To run tests, run the following command
Contributing
If you have a suggestion that would make this better, please fork the repo and create a pull request.
License
LGPLv3