/
xcssecovid.c
684 lines (597 loc) · 26.6 KB
/
xcssecovid.c
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
// xcssecovid.c
// xcssecovid
//
// Created by Dr. Rolf Jansen on 2020-03-22.
// Copyright © 2020 Dr. Rolf Jansen. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Usage:
//
// 1. Compile numerics.c, models.c and xcssecovid.c on either of FreeBSD or macOS:
//
// clang -g0 -O3 -march=native numerics.c models.c xcssecovid.c -Wno-parentheses -lm -o xcssecovid
//
// 2. Download the daily updated time series of confirmed Covid-19 cases
// from CSSE's (at Johns Hopkins University) GitHub site CSSE COVID-19 Dataset
// https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data
//
// fetch https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv
//
// 3. Extract the time series row of a given country starting on 2020-01-21 as day 0
// and write it out together with the country's cases and a simulated curve-fitted
// logistic function into a three-column TSV output file:
//
// ./xcssecovid Germany time_series_covid19_confirmed_global.csv Germany.tsv
//
// 4. Open the TSV file with your favorite graphing and/or data analysis application.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
#include "numerics.h"
#include "models.h"
static const char *version = "Version 1.0.3";
static inline const char *execname(const char *cmd)
{
const char *r = cmd + strlen(cmd);
while (--r >= cmd && *r != '/');
return r + 1;
}
enum
{
no_error,
usg_error,
fs_error,
val_error,
fit_error,
par_error,
sim_error
};
int usage(const char *exe)
{
printf("\nExtract, curve fit an epidemiological model and transpose CSSE@JHU's Covid-19 case data per country - Copyright Dr. Rolf Jansen (c) 2020 - %s\n", version);
printf("Usage: %s [-a<0-9> value] [-f (0-9)+] [-m model] [-e] [-i] [-s] [-o day#] [-z day#] [-r depth] [-h|-?|?] <Country> <CSV Input file> <TSV Output File>\n\n\
-a<0..9> value Optionally set initial values for the model's parameters the Differential Equation Solver and Curve Fitting.\n\
The models deduce its initial parameters from the boundaries of the imported time series and by common\n\
knowledge/best educated guesses. Example: -a0 0.57 -a1 125000\n\n\
-f (0-9)+ Overrides the default selection of a model's parameters which take part in curve fitting, and which usually is a0, a1, a2.\n\
Example: -f 1245 would lead to curve fitting against the paramters a1, a2, a4 and a5, while a0 and a3 would be left untouched.\n\
Different models got different number of parameters, which is currently 3 to 9.\n\n\
-m model Select the model for curve fitting and simulation:\n\
- LF Logistic Function -- https://en.wikipedia.org/wiki/Logistic_function\n\
- LDE Logistic Differential Equation -- https://en.wikipedia.org/wiki/Logistic_function#Logistic_differential_equation\n\
- SI Epidemiological SI-Model (basically another form of the LDE) -- https://de.wikipedia.org/wiki/SI-Modell\n\
- SIR Epidemiological SIR-Model [default] -- https://en.wikipedia.org/wiki/Mathematical_modelling_of_infectious_disease#The_SIR_model\n\
- SEIR Epidemiological SEIR-Model -- https://www.idmod.org/docs/hiv/model-seir.html\n\
- SIRX Extension of the SIR-Model by the HU/RKI -- http://rocs.hu-berlin.de/corona/docs/forecast/model/\n\
- ERF Shifted Error Function -- (generic form) https://en.wikipedia.org/wiki/Error_function\n\
- GLF Generalised Logistic Function -- https://en.wikipedia.org/wiki/Generalised_logistic_function\n\n\
-e Only export the extracted and transposed time series without curve fitting and simulation of the model.\n\n\
-i Only inform the model description and the values of its parameters with or without fitting, but without exporting any curve data.\n\n\
-s Simulate the model without curve fitting before.\n\n\
-t thresh Threshold of minimal number of cases to include into curve fitting and simulation [default: 17].\n\n\
-o day# The day# of the first data point in the imported time series to be included for curve fitting.\n\
[default: first day with more than <thresh> cases].\n\n\
-z day# The day# of the last data point in the imported time series to be included for curve fitting.\n\
[default: last day of the imported series].\n\n\
-q Output the time series of the whole set of the simulated differential equations of the given model along with the extracted CSSE@JHU's Covid-19 case data.\n\n\
-r depth Retrospective day by day curve fitting and simulation of the model back for depth number of days.\n\
(Note: the -q and -r options are mutually exclusive, the last option on the command line counts).\n\n\
-h|-?|? Show these usage instructions.\n\n\
<Country> Select the country for which the time series shall be processed.\n\n\
<CSV Input file> Path to the CSSE@JHU's Covid-19 time series CSV file.\n\n\
<TSV Output File> Path to the TSV output file containing the extracted and transposed time series for the given <Country>, including\n\
one ore more columns for the simulated time series by the given model, using the parameters as resulted from curve fitting.\n\n", exe);
return usg_error;
}
static inline size_t collen(const char *col)
{
if (!col || !*col)
return 0;
size_t l;
for (l = 0; col[l] && col[l] != ','; l++)
;
return l;
}
#define ndays 731 // 2020 is a leap year - t[ 0] = 2020-01-01; t[365] = 2020-12-31
// t[366] = 2021-01-01; t[730] = 2021-12-31
int main(int argc, char *const argv[])
{
int rc = no_error;
const char *exe = execname(argv[0]);
char *model = "SIR";
char *modelDescription = modelDescription_SIR;
initvals initialValues = initialValues_SIR;
function modelFunction = modelFunction_SIR;
bool do_simulation = true,
do_curve_fit = true,
export_series = true,
diffeq_series = false;
int r = 0;
ldouble o = NAN,
z = NAN,
thr = 17.0L;
ldouble A0[mpar] = {NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN},
**A = NULL;
int f[mpar] = {undefined, undefined, undefined, undefined, undefined,
undefined, undefined, undefined, undefined, undefined};
bool aopt = false;
int opc;
while ((opc = getopt(argc, argv, "a0:1:2:3:4:5:6:7:8:9:f:m:eist:o:qr:z:h?")) != -1)
{
char *chk, c;
int i;
long l;
ldouble v;
switch (opc)
{
case 'a':
if (aopt)
return usage(exe);
aopt = true;
break;
case '0' ... '9':
if (aopt && optarg && *optarg)
{
if ('0' <= opc && opc <= '9' && isnan(A0[opc -= '0'])
&& ((v = strtold(optarg, &chk)) != 0.0L || chk != optarg)
&& isfinite(v))
{
A0[opc] = v;
aopt = false;
}
else
return usage(exe);
}
else
return usage(exe);
break;
case 'f':
if (optarg && *optarg)
{
for (i = 0; c = *optarg; optarg++)
if ('0' <= c && c <= '9' && f[i] == -1)
f[i++] = c - '0';
else
return usage(exe);
}
else
return usage(exe);
break;
case 'm':
if (optarg && *optarg)
if (*(uint16_t *)optarg == *(uint16_t *)"LF" && optarg[2] == '\0')
{
model = "LF";
modelDescription = modelDescription_LF;
initialValues = initialValues_LF;
modelFunction = modelFunction_LF;
}
else if (*(uint32_t *)optarg == *(uint32_t *)"LDE")
{
model = "LDE";
modelDescription = modelDescription_LDE;
initialValues = initialValues_LDE;
modelFunction = modelFunction_LDE;
}
else if (*(uint16_t *)optarg == *(uint16_t *)"SI" && optarg[2] == '\0')
{
model = "SI";
modelDescription = modelDescription_SI;
initialValues = initialValues_SI;
modelFunction = modelFunction_SI;
}
else if (*(uint32_t *)optarg == *(uint32_t *)"SIR")
; // default, do nothing
else if (*(uint32_t *)optarg == *(uint32_t *)"SEIR" && optarg[4] == '\0')
{
model = "SEIR";
modelDescription = modelDescription_SEIR;
initialValues = initialValues_SEIR;
modelFunction = modelFunction_SEIR;
}
else if (*(uint32_t *)optarg == *(uint32_t *)"SIRX" && optarg[4] == '\0')
{
model = "SIRX";
modelDescription = modelDescription_SIRX;
initialValues = initialValues_SIRX;
modelFunction = modelFunction_SIRX;
}
else if (*(uint16_t *)optarg == *(uint16_t *)"ERF")
{
model = "ERF";
modelDescription = modelDescription_ERF;
initialValues = initialValues_ERF;
modelFunction = modelFunction_ERF;
}
else if (*(uint16_t *)optarg == *(uint16_t *)"GLF")
{
model = "GLF";
modelDescription = modelDescription_GLF;
initialValues = initialValues_GLF;
modelFunction = modelFunction_GLF;
}
else
return usage(exe);
else
return usage(exe);
break;
case 'e':
do_simulation = false;
do_curve_fit = false;
export_series = true;
break;
case 'i':
do_simulation = true;
export_series = false;
break;
case 's':
do_simulation = true;
do_curve_fit = false;
break;
case 't':
if (optarg && *optarg && (v = strtold(optarg, NULL)) > 0.0L)
thr = v;
else
return usage(exe);
break;
case 'o':
if (optarg && *optarg
&& ((v = strtold(optarg, &chk)) != 0.0L || chk != optarg)
&& (v < z || isnan(z)))
o = v;
else
return usage(exe);
break;
case 'q':
r = 0, diffeq_series = true;
break;
case 'r':
if (optarg && *optarg && (l = strtol(optarg, NULL, 10)) > 0)
diffeq_series = false, r = (int)l;
else
return usage(exe);
break;
case 'z':
if (optarg && *optarg
&& ((v = strtold(optarg, &chk)) != 0.0L || chk != optarg)
&& (v >= o || isnan(o)))
z = v;
else
return usage(exe);
break;
case 'h':
case '?':
default:
return usage(exe);
break;
}
}
if (argc-optind != 3 || argc && argv[optind][0] == '?' && argv[optind][1] == '\0')
return usage(exe);
FILE *csv, *tsv;
char *country = argv[optind];
size_t cl = strlen(country);
if (*country)
{
if (*(uint32_t *)model == *(uint32_t *)"SEIR" && model[4] == '\0'
&& *(uint64_t *)country == *(uint64_t *)"Germany")
{
modelDescription = modelDescription_SEIR_de;
initialValues = initialValues_SEIR_de;
modelFunction = modelFunction_SEIR_de;
}
if (csv = (*(uint16_t *)argv[optind+1] == *(uint16_t *)"-")
? stdin
: fopen(argv[optind+1], "r"))
{
if (tsv = (*(uint16_t *)argv[optind+2] == *(uint16_t *)"-")
? stdout
: fopen(argv[optind+2], "w"))
{
int h, i, j, m = 0, n = 0;
char *line;
char d[65536];
ldouble t[ndays],
c[ndays],
**l = malloc((r+1)*sizeof(ldouble *));
for (h = 0; h <= r; h++)
l[h] = malloc(ndays*sizeof(ldouble));
// day 1 of the CSSE time series is 2020-01-22, hence day 0 is 2020-01-21, i.e. t[20]
for (i = 0; i < ndays; i++)
t[i] = i - 20, c[i] = NAN;
for (h = 0; h <= r; h++)
for (i = 0; i < ndays; i++)
l[h][i] = NAN;
// find the lines with the series of the specified country
while (line = fgets(d, 65536, csv))
{
size_t len = strlen(line);
size_t col = collen(line);
if (len != col && (line = strstr(line+col+1, country)) && line[cl] == ',')
{
// skip 3 more fields (Country/Region,Lat,Long)
for (i = 0; i < 3; i++)
line += collen(line) + 1;
// read the case numbers and sum it up into the c array, starting at day 1 = index 20+1;
int p, q = p = 21;
while (*line && *line != '\n' && *line != '\r')
{
char *chk;
ldouble v = strtod(line, &chk);
if (chk > line && isfinite(v))
{
if (isnan(c[q]))
c[q] = v;
else
c[q] += v;
line = chk + 1;
}
else
line += collen(line) + 1;
q++;
}
if (q > p)
{
if (p > m) m = p;
if (q > n) n = q;
}
}
}
if (isfinite(o))
{
for (i = 0; t[i] != o && i < ndays; i++);
if (i < ndays && isfinite(c[i]))
m = i;
else
return usage(exe);
}
else
for (; isfinite(c[m]) && c[m] < thr && m < n; m++);
if (isfinite(z))
{
for (i = ndays-1; t[i] != z && i >= 0; i--);
if (i >= 0 && isfinite(c[i]))
n = i + 1;
else
return usage(exe);
}
if (n > m)
if (r < n-m - 3)
{
fprintf(tsv, "# %s", exe);
for (i = 1; i < argc; i++)
fprintf(tsv, " %s", argv[i]);
fprintf(tsv, "\n# %s\n# Time base: 1 d\n", country);
if (do_simulation)
{
A = malloc((r+1)*sizeof(ldouble *));
for (h = 0; h <= r; h++)
A[h] = malloc(mpar*sizeof(ldouble));
for (j = 0; j < mpar; j++)
A[0][j] = A0[j];
int k = initialValues(t[m], c[m], c[n-1], A[0], f);
if (do_curve_fit)
{
ldouble chiSqr = NAN;
ldouble dA[mpar] = {};
if (isfinite(chiSqr = curveFit(n-m, &t[m], &c[m], k, A[0], dA, f, modelFunction)))
{
fprintf(tsv, "%s\n#\n", modelDescription);
for (j = 0; j < mpar && isfinite(A[0][j]); j++)
if (dA[j] != 0.0L)
fprintf(tsv, "# %c%d = %11.6Lg ± %.5Lg %%\n", 'a', j, A[0][j], dA[j]);
else
fprintf(tsv, "# %c%d = %11.6Lg\n", 'a', j, A[0][j]);
fprintf(tsv, "#\n# ChiSqr = %11.1Lf\n", chiSqr);
}
else
{
fprintf(tsv,
"# Curve fit failed\n");
printf("Curve fit failed\n");
rc = fit_error;
goto cleanup;
}
if (rc == no_error && r)
{
for (h = 1; h <= r; h++)
{
for (j = 0; j < mpar; j++)
A[h][j] = A0[j], dA[j] = 0.0L;
initialValues(t[m], c[m], c[n-1 - h], A[h], f);
if (isfinite(chiSqr = curveFit(n-m - h, &t[m], &c[m], k, A[h], dA, f, modelFunction)))
{
fprintf(tsv, "#\n# Retropective curve fit #%d:\n%s\n#\n", h, modelDescription);
for (j = 0; j < mpar && isfinite(A[h][j]); j++)
if (dA[j] != 0.0L)
fprintf(tsv, "# %c%d = %11.6Lg ± %.5Lg %%\n", 'a', j, A[h][j], dA[j]);
else
fprintf(tsv, "# %c%d = %11.6Lg\n", 'a', j, A[h][j]);
fprintf(tsv, "#\n# ChiSqr = %11.1Lf\n", chiSqr);
}
else
{
fprintf(tsv,
"# Retrospective curve fit #%d failed\n", h);
printf("Retrospective curve fit #%d failed\n", h);
rc = fit_error;
break;
}
}
fprintf(tsv, "#\n# Std. Dev. of all parameters of the retrospection over %d days\n", r+1);
ldouble *Z = malloc((r+1)*sizeof(ldouble));
for (j = 0; j < mpar && isfinite(A[0][j]); j++)
{
for (h = 0; h <= r; h++)
Z[h] = A[h][j];
if (dA[j] != 0.0L)
fprintf(tsv, "# s%c%d = %11.6Lg %%\n", 'a', j, sdev(r+1, Z)/aave(r+1, Z)*100.0L);
}
free(Z);
}
}
else
{
fprintf(tsv, "%s\n#\n", modelDescription);
for (j = 0; j < mpar && isfinite(A[0][j]); j++)
fprintf(tsv, "# %c%d = %11.6Lg\n", 'a', j, A[0][j]);
fprintf(tsv, "#\n");
}
if (rc == no_error && export_series)
if (diffeq_series)
{
// write the column header with formular symbols and units.
// - the formular symbol of time is 't', the unit symbol of day is 'd'
// - the formular symbol of the number of cases is C without a unit
// - the formular symbol of the simulated model is deduced from the model's name
fprintf(tsv, "t/d\tC");
for (k = 0; model[k]; k++)
fprintf(tsv, "\t%c", model[k]);
fprintf(tsv, "\n");
ldouble *Y = calloc(k+1, sizeof(ldouble));
for (i = 0; i < ndays; i++)
{
if (i >= m)
if (modelFunction(t[i], Y, A[0], f, false, i == m) != no_error)
goto sim_err_out;
if (isfinite(c[i]))
fprintf(tsv, "%.0Lf\t%.0Lf", t[i], c[i]);
else
fprintf(tsv, "%.0Lf\t*", t[i]);
for (h = 0; h < k && isfinite(Y[h]); h++)
fprintf(tsv, "\t%.0Lf", Y[h]);
fprintf(tsv, "\n");
}
free(Y);
}
else
{
// write the column header with formular symbols and units.
// - the formular symbol of time is 't', the unit symbol of day is 'd'
// - the formular symbol of the number of cases is C without a unit
// - the formular symbol of the siumulated model is L without a unit
fprintf(tsv, "t/d\tC\tL");
if (!r)
fprintf(tsv, "\n");
else
{
for (h = 0; h < r; h++)
fprintf(tsv, "%d\tL", h);
fprintf(tsv, "%d\n", h);
}
for (h = 0; h <= r; h++)
for (i = 0; i < ndays; i++)
{
if (i >= m)
{
if (modelFunction(t[i], &l[h][i], A[h], f, true, i == m) != no_error)
goto sim_err_out;
}
else
l[h][i] = 0.0L;
}
for (i = 0; i < ndays; i++)
{
if (isfinite(c[i]))
fprintf(tsv, "%.0Lf\t%.0Lf", t[i], c[i]);
else
fprintf(tsv, "%.0Lf\t*", t[i]);
for (h = 0; h <= r; h++)
if (isfinite(l[h][i]))
fprintf(tsv, "\t%.0Lf", l[h][i]);
else
fprintf(tsv, "\t*");
fprintf(tsv, "\n");
}
goto cleanup;
sim_err_out:
fprintf(tsv,
"# Simulation failed\n");
printf("Simulation failed\n");
rc = sim_error;
}
cleanup:
if (A)
{
for (h = 0; h <= r; h++)
free(A[h]);
free(A);
}
}
else
{
// write the column header with formular symbols and units.
// - the formular symbol of time is 't', the unit symbol of day is 'd'
// - the formular symbol of the number of cases is C without a unit
fprintf(tsv, "t/d\tC\n");
for (i = 0; i < ndays; i++)
{
if (isfinite(c[i]))
fprintf(tsv, "%.0Lf\t%.6Lf\n", t[i], c[i]);
else
fprintf(tsv, "%.0Lf\t*\n", t[i]);
}
}
for (h = 0; h <= r; h++)
free(l[h]);
free(l);
}
else
{
fprintf(tsv,
"# The retrospective depth #%d is too large\n", r);
printf("The retrospective depth #%d is too large\n", r);
rc = par_error;
}
else
{
fprintf(tsv,
"# No values for country %s encountered.\n", country);
printf("No values for country %s encountered.\n", country);
rc = val_error;
}
if (tsv != stdout)
fclose(tsv);
}
else
{
printf("Output file %s could not be opened for writing.\n", argv[optind+2]);
rc = fs_error;
}
if (csv != stdin)
fclose(csv);
}
else
{
printf("Input file %s not found.\n", argv[optind+1]);
rc = fs_error;
}
}
return rc;
}