67typedef struct CSV_row CSV_row;
136typedef struct CSV_reader CSV_reader;
274typedef struct CSV_writer CSV_writer;
CSV_status CSV_reader_read_v(CSV_reader *reader,...)
Reads fields into variadic arguments.
bool CSV_reader_eof(const CSV_reader *reader)
Check for end of input.
CSV_reader * CSV_reader_init_from_filename(const char *filename)
Create a new CSV_reader object parsing from a file.
void CSV_reader_set_delimiter(CSV_reader *reader, const char delimiter)
Change delimiter character.
const char * CSV_reader_get_error_msg(const CSV_reader *reader)
Get message for last error.
CSV_row * CSV_reader_read_row(CSV_reader *reader)
Read the current row from the CSV file and advance to the next.
void CSV_reader_free(CSV_reader *reader)
Free a CSV_reader object.
void CSV_reader_set_quote(CSV_reader *reader, const char quote)
Change the quote character.
CSV_reader * CSV_reader_init_from_file(FILE *file)
Create a new CSV_reader object parsing from a FILE *.
char * CSV_reader_read_field(CSV_reader *reader)
Read a single field.
CSV_status CSV_reader_get_error(const CSV_reader *reader)
Get error code for last error.
CSV_status CSV_reader_read_row_ptr(CSV_reader *reader, char ***fields, size_t *num_fields)
Read a row into an array of strings.
void CSV_reader_set_lenient(CSV_reader *reader, const bool lenient)
Enable / disable lenient parsing.
bool CSV_reader_end_of_row(const CSV_reader *reader)
Check for end of current row.
CSV_reader * CSV_reader_init_from_str(const char *input)
Create a new CSV_reader object parsing from an in-memory string.
size_t CSV_row_size(const CSV_row *rec)
Get CSV_Record array size.
CSV_row * CSV_row_init(void)
Create a new CSV_row.
const char *const * CSV_row_arr(const CSV_row *rec)
CSV_row array access.
void CSV_row_free(CSV_row *rec)
Free a CSV_row.
const char * CSV_row_get(const CSV_row *rec, size_t i)
CSV_row array element access.
CSV_status CSV_row_read_v(CSV_row *rec,...)
Reads fields into variadic arguments.
void CSV_row_append(CSV_row *rec, char *field)
Append a new field.
CSV_status CSV_writer_write_row_ptr(CSV_writer *writer, const char *const *fields, const size_t num_fields)
Write an array of strings as a row.
CSV_status CSV_writer_end_row(CSV_writer *writer)
End the current row.
CSV_status CSV_writer_write_row_v(CSV_writer *writer,...)
Write a row from the given variadic parameters.
CSV_status CSV_writer_write_row(CSV_writer *writer, const CSV_row *fields)
Write a CSV_row.
CSV_status CSV_writer_write_fields_ptr(CSV_writer *writer, const char *const *fields, const size_t num_fields)
Write an array of strings without ending the current row.
CSV_writer * CSV_writer_init_from_filename(const char *filename)
Create a new CSV_writer object writing to a file.
void CSV_writer_free(CSV_writer *writer)
Free a CSV_writer object.
CSV_status CSV_writer_write_fields_v(CSV_writer *writer,...)
Write from the given variadic parameters without ending the current row.
CSV_status CSV_writer_write_fields(CSV_writer *writer, const CSV_row *fields)
Write a CSV_row without ending the current row.
CSV_writer * CSV_writer_init_from_file(FILE *file)
Create a new CSV_writer object writing to a FILE *.
CSV_status CSV_writer_write_field(CSV_writer *writer, const char *field)
Write a single field.
void CSV_writer_set_quote(CSV_writer *writer, const char quote)
Change the quote character.
const char * CSV_writer_get_str(CSV_writer *writer)
Get the string output.
void CSV_writer_set_delimiter(CSV_writer *writer, const char delimiter)
Change delimiter character.
CSV_writer * CSV_writer_init_to_str(void)
Create a new CSV_writer object writing to a string.
char * CSV_strdup(const char *src)
strdup implementation, in case it's not implemented in string.h
CSV_status
Status codes.
Definition csv.h:45
@ CSV_INTERNAL_ERROR
Illegal reader / writer state reached.
Definition csv.h:51
@ CSV_EOF
Reached end of file.
Definition csv.h:47
@ CSV_OK
No errors, ready to read / write another field.
Definition csv.h:46
@ CSV_TOO_MANY_FIELDS_WARNING
More fields exist in one row than will fit in given storage. Non fatal.
Definition csv.h:50
@ CSV_PARSE_ERROR
Parsing error. See CSV_reader_get_error_msg for details.
Definition csv.h:48
@ CSV_IO_ERROR
IO error.
Definition csv.h:49