Skip to content

Commit

Permalink
csv with dots on the header text now work properly
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl committed Oct 11, 2024
1 parent be89096 commit e9e6efa
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/api/csv/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const csv = (readStream: Readable, stopOnError = false) => ({

async read() {
this.reading = true;
return csvtojson({ delimiter: DELIMITERS })
return csvtojson({ delimiter: DELIMITERS, flatKeys: true })
.fromStream(readStream)
.subscribe(async (row: CSVRow, index) => {
if (!this.reading) {
Expand Down
1 change: 1 addition & 0 deletions app/api/csv/specs/csvLoader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ describe('csvLoader', () => {
numeric_label: [{ value: 1977 }],
select_label: [{ label: 'thesauri1', value: expect.any(String) }],
text_label: [{ value: 'text value 1' }],
header_with_dots: [{ value: 'header with dots value 1' }],
});
});

Expand Down
5 changes: 5 additions & 0 deletions app/api/csv/specs/csvLoaderFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export default {
label: 'text label',
name: templateUtils.safeName('text label'),
},
{
type: propertyTypes.text,
label: 'header.with. dots',
name: templateUtils.safeName('header.with.dots'),
},
{
type: propertyTypes.numeric,
label: 'numeric label',
Expand Down
8 changes: 4 additions & 4 deletions app/api/csv/specs/test.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Title , text label , numeric label, non configured, select_label, not defined type, geolocation_geolocation,auto id, additional tag(s), Multi Select Label, Date label, Language
Title , header.with.dots, text label , numeric label, non configured, select_label, not defined type, geolocation_geolocation,auto id, additional tag(s), Multi Select Label, Date label, Language

title1, text value 1, 1977, ______________, thesauri1 , notType1 , 1|1,,tag1, multivalue1,03/01/2022,English
title2, text value 2, 2019, ______________, thesauri2 , notType2 , ,,tag2, multivalue2,01/03/2022,Spanish
title3, text value 3, 2020, ______________, thesauri2 , notType3 , 0|0,,tag3, multivalue1|multivalue3,01/01/2022,AnyStringIsGood
title1, header with dots value 1, text value 1, 1977, ______________, thesauri1 , notType1 , 1|1,,tag1, multivalue1,03/01/2022,English
title2, header with dots value 2, text value 2, 2019, ______________, thesauri2 , notType2 , ,,tag2, multivalue2,01/03/2022,Spanish
title3, header with dots value 3, text value 3, 2020, ______________, thesauri2 , notType3 , 0|0,,tag3, multivalue1|multivalue3,01/01/2022,AnyStringIsGood
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"hot-e2e": "DATABASE_NAME=uwazi_e2e INDEX_NAME=uwazi_e2e EXTERNAL_SERVICES=true yarn hot",
"run-e2e": "DATABASE_NAME=uwazi_e2e INDEX_NAME=uwazi_e2e EXTERNAL_SERVICES=true yarn run-production",
"hot-inspect": "export HOT=true; export BABEL_ENV=debug; yarn run watch-types & yarn dev-server --inspect & yarn run webpack-server",
"hot-debug": "export HOT=true; export BABEL_ENV=debug; node --no-experimental-fetch --inspect-brk=9229 server.js",
"hot-debug": "export HOT=true; export BABEL_ENV=debug; node --no-experimental-fetch --inspect-brk=9229 server.js & yarn run webpack-server",
"reindex": "node scripts/run.js ../database/reindex_elastic.js",
"import-csv": "node --no-experimental-fetch scripts/run.js ../database/import_csv.js",
"blank-state": "node --no-experimental-fetch scripts/bash.js ./database/blank_state.sh",
Expand Down

0 comments on commit e9e6efa

Please sign in to comment.