1
1
#include " ../include/harrizcsv.h"
2
2
#include " ../include/mark.h"
3
3
#include " ../include/student.h"
4
- #include " ../include/resource.h "
4
+ #include < unistd.h >
5
5
6
6
using namespace std ;
7
7
8
8
int main (int argc, char **argv)
9
9
{
10
+ cout << getcwd (0 ,0 ) << endl;
10
11
char *lpFn = new char [1024 ];
11
12
char *only = new char [256 ];
12
13
char *exclude = new char [256 ];
13
14
char *outputFn = new char [1024 ];
14
15
15
16
strcpy (lpFn, " data/SCHS21-1.csv" );
16
17
strcpy (outputFn, " data/output.csv" );
18
+ strcpy (only, " " );
19
+ strcpy (exclude, " " );
17
20
18
21
int n_terms = 0 ;
19
22
char c;
20
- while ((c = getopt (argc, argv, " :f:n:e:i" )) != -1 )
23
+ while ((c = getopt (argc, argv, " :f:n:e:i:o " )) != -1 )
21
24
{
22
25
switch (c)
23
26
{
@@ -33,6 +36,9 @@ int main(int argc, char **argv)
33
36
case ' i' :
34
37
strncpy (only, optarg , 256 );
35
38
break ;
39
+ case ' o' :
40
+ strncpy (outputFn, optarg , 256 );
41
+ break ;
36
42
case ' ?' :
37
43
if (optopt == ' f' || optopt == ' n' || optopt == ' e' || optopt == ' i' )
38
44
fprintf (stderr, " Option -%c requires an argument.\n " , optopt );
@@ -70,7 +76,7 @@ int main(int argc, char **argv)
70
76
strcpy (new_student->a , columns->at (1 ));
71
77
for (int col = 2 ; col < columns->size (); col++)
72
78
{
73
- if (strcmp (headers->at (col), " O.A" ) == 0 )
79
+ if (strncmp (headers->at (col), " O.A" , 3 ) == 0 )
74
80
{
75
81
new_student->OAs .push_back (Mark (columns->at (col)));
76
82
}
@@ -154,8 +160,13 @@ int main(int argc, char **argv)
154
160
outfile << student->OAs .at (iterm).to_int () << " ;" ;
155
161
for (int isum = 0 ; isum < n_summatives; isum++)
156
162
outfile << student->Summatives .at (isum).to_int () << " ;" ;
157
- for (int iex = 0 ; iex < n_exams; iex++)
158
- outfile << student->Exams .at (iex).to_int () << " ;" ;
163
+ for (int iex = 0 ; iex < n_exams; iex++) {
164
+ int exmark = student->Exams .at (iex).to_int ();
165
+ if (exmark == -1000000 )
166
+ outfile << " A" << " ;" ;
167
+ else
168
+ outfile << exmark << " ;" ;
169
+ }
159
170
outfile << " ;;" << student->term_mark (n_terms).to_int () << " ;" ;
160
171
outfile << student->final_mark (n_terms).to_int ();
161
172
outfile << endl;
@@ -182,8 +193,13 @@ int main(int argc, char **argv)
182
193
outfile << student->OAs .at (iterm).to_int () << " ;" ;
183
194
for (int isum = 0 ; isum < n_summatives; isum++)
184
195
outfile << student->Summatives .at (isum).to_int () << " ;" ;
185
- for (int iex = 0 ; iex < n_exams; iex++)
186
- outfile << student->Exams .at (iex).to_int () << " ;" ;
196
+ for (int iex = 0 ; iex < n_exams; iex++) {
197
+ int exmark = student->Exams .at (iex).to_int ();
198
+ if (exmark == -1000000 )
199
+ outfile << " A" << " ;" ;
200
+ else
201
+ outfile << exmark << " ;" ;
202
+ }
187
203
outfile << " ;;" << student->term_mark (n_terms).to_int () << " ;" ;
188
204
outfile << student->final_mark (n_terms).to_int ();
189
205
outfile << endl;
@@ -193,4 +209,4 @@ int main(int argc, char **argv)
193
209
outfile.close ();
194
210
195
211
return 0 ;
196
- }
212
+ }
0 commit comments