csv

csv reading library
git clone git://bvnf.space/csv.git
Log | Files | Refs

csv.3 (1088B)


      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
.\" To view this file, run: man ./csv.3
.Dd October 2, 2021
.Dt CSV 3
.Os "ben's space"
.Sh NAME
.Nm csv_read_file ,
.Nm csv_create ,
.Nm csv_destroy
.Nd parse csv data
.Sh LIBRARY
.Lb csv
.Sh SYNOPSIS
.In csv.h
.Bd -literal
struct csv {
    int cols, rows;
    char **headers;    /* array of strings */
    float **data;      /* array of arrays of floats */
};

.Ed
.Ft int
.Fn csv_read_file "FILE *stream" "struct csv *c" "char hdr"
.Ft struct csv *
.Fn csv_create
.Ft void
.Fn csv_destroy "struct csv *c"
.Sh DESCRIPTION
These functions reads csv data from
.Va stream
into memory, parsing each cell as a
.Va float .
.Pp
If
.Va hdr
is set,
.Nm
parses the first line of
.Va stream
for column header names which are placed into
.Va c->headers .
.El
.Pp
The number of columns in the first row is set as the intended number
of cells for every row. Extra cells on subsequent rows will be ignored.
Any cells which are empty or missing will be set to
.Va 0 ,
and a warning will be printed.
.Pp
This manual documents version
.Va 1.0
of
.Nm libcsv .
.Sh AUTHORS
.An phoebos Aq Mt ben@bvnf.space