aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorTadas Vilkeliskis <vilkeliskis.t@gmail.com>2026-06-11 21:12:09 -0400
committerTadas Vilkeliskis <vilkeliskis.t@gmail.com>2026-06-11 21:12:09 -0400
commit9a9c575aa64068037d068d40c08873468126a943 (patch)
tree4aedf276947270ee49821584bc50b4210bd9acf7 /README.md
parent8049d751271b37d8f66ea482f96c09a286b9b06c (diff)
docs: update README with pkg-config usage and quick start example
Diffstat (limited to 'README.md')
-rw-r--r--README.md79
1 files changed, 59 insertions, 20 deletions
diff --git a/README.md b/README.md
index d52de5b..4f2789a 100644
--- a/README.md
+++ b/README.md
@@ -1,30 +1,69 @@
-csv_parser [![Build Status](https://travis-ci.org/tadasv/csv_parser.png?branch=master)](https://travis-ci.org/tadasv/csv_parser)
-==========
+# csv_parser
This library provides a CSV parser to be used in an event loop for processing large amounts of streaming data.
-The parser itself does not use any internal buffers. Whenever field value is available a user's specified callback
-will be invoked with field data and CSV location (row and column).
+The parser itself does not use any internal buffers. Whenever a field value is available, a user's specified callback will be invoked with the field data and its CSV location (row and column).
-See ``examples`` for more information.
-
-Building
---------
+## Building & Installation
Prerequisites:
-
- * gcc
- * libtool
- * autoconf
- * automake
- * check (to build tests)
+* gcc
+* libtool
+* autoconf
+* automake
+* check (to build tests)
To build and install:
- $ sh autogen.sh
- $ ./configure
- $ make
- $ make install
-
+```bash
+$ sh autogen.sh
+$ ./configure
+$ make
+$ make install
+```
+
You can optionally build and run tests:
- $ make test
+```bash
+$ make test
+```
+
+## Usage
+
+Once installed, you can link your own projects against the library using `pkg-config`:
+
+```bash
+$ gcc my_program.c -o my_program $(pkg-config --cflags --libs csv_parser)
+```
+
+### Quick Example
+
+Here is a minimal example demonstrating how to initialize the parser and process data:
+
+```c
+#include <stdio.h>
+#include <string.h>
+#include <csv_parser.h>
+
+int on_field(csv_parser_t *parser, const char *data, size_t length, int row, int col) {
+ printf("Row: %d, Col: %d, Value: %.*s\n", row, col, (int)length, data);
+ return 0;
+}
+
+int main() {
+ csv_parser_t parser;
+ csv_parser_init(&parser);
+
+ csv_parser_settings_t settings = {
+ .delimiter = ',',
+ .field_cb = on_field
+ };
+
+ const char *csv_data = "name,age\nAlice,30\nBob,25";
+ csv_parser_execute(&parser, &settings, csv_data, strlen(csv_data));
+ csv_parser_finish(&parser, &settings);
+
+ return 0;
+}
+```
+
+See the `examples/` directory for more advanced use cases.