diff --git a/packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts b/packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts index 01390ecb4e..1e1c50b8de 100644 --- a/packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts +++ b/packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts @@ -179,8 +179,10 @@ export default class CSVTemplateAdapter { ) { this.tables[tableIdx].columns[columnIdx].uidt = UITypes.Date // take the date format with the max occurrence - this.tables[tableIdx].columns[columnIdx].meta.date_format = - Object.keys(dateFormat).reduce((x, y) => (dateFormat[x] > dateFormat[y] ? x : y)) || 'YYYY/MM/DD' + const objKeys = Object.keys(dateFormat) + this.tables[tableIdx].columns[columnIdx].meta.date_format = objKeys.length + ? objKeys.reduce((x, y) => (dateFormat[x] > dateFormat[y] ? x : y)) + : 'YYYY/MM/DD' } else { // Datetime this.tables[tableIdx].columns[columnIdx].uidt = uidt