-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen_csv.h
More file actions
84 lines (67 loc) · 2.4 KB
/
Copy pathopen_csv.h
File metadata and controls
84 lines (67 loc) · 2.4 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* Author(s): Arda T. Kersu
* File name: open_csv.c
* Date: 1st November 2023
*
* Description: Header file for the library "open_csv.h" that provides easier handling and manipulation of
* '.csv' files with the use of C programming language. See inline comments on the source file
* for further details regarding any specific function of interest.
*
* Disclaimer: This open-source project is provided "as is" without any warranty, expressed or implied.
* The contributors and maintainers disclaim any an all unintended consequences or issues
* that may arise from its use. Users are encouraged to review and understand the software's
* characteristics before implementation.
*
*
* Copyright @ [Arda T. Kersu]
*
*/
#ifndef DML_OPEN_CSV_H
#define DML_OPEN_CSV_H
#include "inc/utils.h"
#include <time.h>
#define CSV_PATH "../datasets/heart.csv"
#define CSV_MODE "r"
#define CSV_DELIM ","
#define HIGH_DATAFRAME_DETAIL (0) //turn this on to include more details about the dataframe
#define MAX_ALLOWED_FEATURE_NAMES (20) //maximum of 20 features per dataset by default
#define MAX_ALLOWED_FEATURE_VALUE (25000) //vector size
#define CSV_NUM_OF_ROWS_AT_HEAD (5)
#define CSV_NUM_OF_ROWS_AT_TAIL (5)
#define CSV_NUM_OF_ROWS_AT_RANDOM (5)
typedef enum {FALSE, TRUE, ERROR = -1} bool_t;
#if HIGH_DATAFRAME_DETAIL == 0
typedef struct
{
char delim;
int rows;
int cols;
long size;
char *features[MAX_ALLOWED_FEATURE_NAMES];
float dataFrame[MAX_ALLOWED_FEATURE_VALUE][MAX_ALLOWED_FEATURE_NAMES];
}csvData_t;
#else
typedef struct
{
char *delim;
int rows;
int cols;
char *params;
long DFSize;
float *maxFeatureValues;
float *minFeatureValues;
float **dataFrame;
}csvData_t;
#endif
static void closeFile(FILE *filePtr);
static void getFrameSize(csvData_t df);
static csvData_t createDataFrame(void);
char *trimToken(char *token);
void getMinAndMaxFeatureValues(csvData_t *df);
csvData_t loadCsv(void);
void DF_get_featureNames(csvData_t df);
void DF_get_frameSize(csvData_t df);
void DF_get_head(csvData_t df);
void DF_get_tail(csvData_t df);
void DF_get_randomSamples(csvData_t df);
#endif //DML_OPEN_CSV_H