51 static void csv_finalize (
void) {
53 for (root = csv_vector; root != NULL; root = next) {
58 if (csv_header != NULL) {
66 static void csv_validate_str (
char *
n) {
68 if (!isalpha (*p)) *p =
'_';
71 if (!isalnum (*p) && *p !=
'.' && *p !=
',' && *p !=
'[' && *p !=
']')
78 static void csv_create_dataset (
int len) {
79 vector * dep, * indep, * v;
90 n = csv_header ? csv_header->
get (0) : (
char *)
"x";
96 for (
int i = 1;
i < len;
i++) {
98 n = csv_header ? csv_header->
get (
i) : NULL;
100 sprintf (depn,
"y%d",
i);
103 csv_validate_str (n);
110 for (v = csv_vector; v != NULL; v = (
vector *) v->
getNext ()) {
113 for (l = 0; l < v->
getSize () - 1; l++) {
128 int len = -1, errors = 0;
131 if (csv_vector == NULL) {
139 if (len == -1) len = v->
getSize ();
143 "csv data line\n", v->
getSize (), len);
149 if (csv_header && csv_header->
length () != len) {
151 "data and header lines\n", csv_header->
length (), len);
156 csv_create_dataset (len);
163 return errors ? -1 : 0;
169 if (csv_result != NULL) {
174 if (csv_vector != NULL) {