Skip to content

Commit 605bda5

Browse files
committed
fixed the flag; new tests
1 parent dee8411 commit 605bda5

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/modules/CSVFileModule.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ class CSVFileModule {
1515
// https://csv.js.org/parse/options/skip_empty_lines/
1616
skip_empty_lines: true,
1717
// NOTE: This will skip any records with empty values, not just skip the empty values themselves
18+
// NOTE-2: The name of the flag changed from v4 (what we use) to v5 (what is documented)
1819
// https://csv.js.org/parse/options/skip_records_with_empty_values/
19-
skip_records_with_empty_values: true,
20+
skip_lines_with_empty_values: true,
2021
});
22+
2123
this.filePath = csvFilePath;
2224
this.data = normalizeEmptyValues(parsedData, unalterableColumns);
2325
}

test/modules/CSVFileModule.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ describe('CSVFileModule', () => {
2323
});
2424

2525
test('Reads data from CSV with Empty Values', async () => {
26+
// Five row file, with three rows of empty values
27+
// Should be just two rows of data after ingestion
2628
const csvFileModuleWithEmptyValues = new CSVFileModule(
2729
path.join(__dirname, './fixtures/example-csv-empty-values.csv'),
2830
);
2931
const data = await csvFileModuleWithEmptyValues.get('mrn', 'example-mrn-1');
3032
expect(data).toEqual(exampleResponse);
33+
const data2 = await csvFileModuleWithEmptyValues.get('mrn', 'example-mrn-not-ignored');
34+
expect(data2).toHaveLength(1);
35+
// Should be just two rows of data after ingestion
36+
expect(csvFileModuleWithEmptyValues.data).toHaveLength(2);
3137
});
3238

3339
test('Reads data from CSV with Empty Lines', async () => {
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
mrn,trialSubjectID,enrollmentStatus,trialResearchID,trialStatus,dateRecorded
22
example-mrn-1,subjectId-1,status-1,researchId-1,trialStatus-1,2020-01-10
3-
, , , \t\t\t,,\t
4-
example-mrn-2,subjectId-3,status-3,researchId-3,trialStatus-3,2020-06-10
3+
, , , , ,
4+
, , , ,,
5+
,,, , ,
6+
example-mrn-not-ignored,,,,,

0 commit comments

Comments
 (0)