csvutil.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* csvutil.h
  2. *
  3. * Utility functions for reading simple CSV files ("comma separated values").
  4. * The declarations follow the Modelica specification for external functions.
  5. *
  6. * Copyright (c) 2004,2005 Dynasim AB.
  7. * All rights reserved.
  8. */
  9. #ifndef CSVUTIL_H
  10. #define CSVUTIL_H
  11. #include <stddef.h>
  12. #if defined(__cplusplus) && !defined(COMPILE_AS_CPLUSPLUS)
  13. extern "C" {
  14. #endif
  15. /* readCSVsizes() - read sizes from a CSV text file */
  16. extern void readCSVsizes(const char* filename /* File containing the data */,
  17. int* sizes /* Returns number of rows, columns, row legends, column legends */,
  18. size_t sizes_dim1);
  19. /* readCSVdata() - read data from a text file with comma separated values */
  20. extern void readCSVmatrixInternal(const char* filename /* File containing the data */,
  21. int n_rows /* Number of rows */,
  22. int n_columns /* Number of columns */,
  23. double* data /* Read data, size n_rows*n_columns */,
  24. size_t data_dim1,
  25. size_t data_dim2);
  26. extern void readCSVHeadersInternal(const char* filename /* File containing the data */,
  27. int n_columns /* Number of columns */,
  28. const char** data,const char*sAlloc(const char*)); /* Data must be initialized before call - if sAlloc returns null the value is not changed */
  29. /* write CSV file */
  30. int WriteCSVmatrixInternal(const char*fname, double*values, size_t rows, size_t columns,
  31. const char*const*headers, const char*separator, int quoteAll);
  32. #if defined(__cplusplus) && !defined(COMPILE_AS_CPLUSPLUS)
  33. }
  34. #endif
  35. #endif