Compare commits

...

3 Commits

Author SHA1 Message Date
semantic-release-bot 47638becc0 chore(release): 6.6.2 [skip ci]
## [6.6.2](https://git.datacontroller.io/dc/dc/compare/v6.6.1...v6.6.2) (2024-02-22)

### Bug Fixes

* excel with commas getting wrapped in quotes ([3860134](38601346a5))
2024-02-22 12:33:10 +00:00
allan bdd3a95685 Merge pull request 'excel with commas getting wrapped in quotes' (#80) from issue-77 into main
Release / Build-production-and-ng-test (push) Successful in 4m13s Details
Release / Build-and-test-development (push) Successful in 7m44s Details
Release / release (push) Successful in 6m15s Details
Reviewed-on: #80
Reviewed-by: sabir <sabir@4gl.io>
2024-02-22 12:19:34 +00:00
Mihajlo Medjedovic 38601346a5 fix: excel with commas getting wrapped in quotes
Build / Build-and-ng-test (pull_request) Failing after 15s Details
2024-02-21 14:48:42 +01:00
4 changed files with 47 additions and 16 deletions

View File

@ -1,3 +1,10 @@
## [6.6.2](https://git.datacontroller.io/dc/dc/compare/v6.6.1...v6.6.2) (2024-02-22)
### Bug Fixes
* excel with commas getting wrapped in quotes ([3860134](https://git.datacontroller.io/dc/dc/commit/38601346a529cfe3787bb286a639e0293c365020))
## [6.6.1](https://git.datacontroller.io/dc/dc/compare/v6.6.0...v6.6.1) (2024-02-19)

View File

@ -940,13 +940,30 @@ export class EditorComponent implements OnInit, AfterViewInit {
return row.map((col: any, index: number) => {
if (!col && col !== 0) col = ''
if (isNaN(col)) {
col = col.replace(/"/g, '""')
/**
* Keeping this for the reference
* Code below used to convert JSON to CSV
* now the XLSX is converting to CSV
*/
// if (isNaN(col)) {
// // Match and replace the double quotes, ignore the first and last char
// // in case they are double quotes already
// col = col.replace(/(?<!^)"(?!$)/g, '""')
if (col.search(/,/g) > -1) {
col = '"' + col + '"'
}
}
// if (col.search(/,/g) > -1 ||
// col.search(/\r|\n/g) > -1
// ) {
// // Missing quotes at the end
// if (col.search(/"$/g) < 0) {
// col = col + '"' // So we add them
// }
// // Missing quotes at the start
// if (col.search(/^"/g) < 0) {
// col = '"' + col // So we add them
// }
// }
// }
const colName = this.headerShow[index]
const colRule = this.dcValidator?.getRule(colName)
@ -961,20 +978,27 @@ export class EditorComponent implements OnInit, AfterViewInit {
this.data = csvArrayData
let csvContent = csvArrayHeaders.join(',') + '\n'
// Apply licence rows limitation if exists
csvContent += csvArrayData
.slice(0, this.licenceState.value.submit_rows_limit)
.map((e) => e.join(','))
.join('\n')
// Apply licence rows limitation if exists, it is only affecting data
// which will be send to SAS
const strippedCsvArrayData = csvArrayData.slice(0, this.licenceState.value.submit_rows_limit)
// To submit to sas service, we need clean version of CSV of file
// attached. XLSX will do the parsing and heavy lifting
// First we create worksheet of json (data we extracted)
let ws = XLSX.utils.json_to_sheet(strippedCsvArrayData, {
skipHeader: true
});
// create CSV to be uploaded from worksheet
let csvContentClean = XLSX.utils.sheet_to_csv(ws);
// Prepend headers
csvContentClean = csvArrayHeaders.join(',') + '\n' + csvContentClean
if (this.encoding === 'WLATIN1') {
let encoded = iconv.decode(Buffer.from(csvContent), 'CP-1252')
let encoded = iconv.decode(Buffer.from(csvContentClean), 'CP-1252')
let blob = new Blob([encoded], { type: 'application/csv' })
let newCSVFile: File = this.blobToFile(blob, this.filename + '.csv')
this.uploader.addToQueue([newCSVFile])
} else {
let blob = new Blob([csvContent], { type: 'application/csv' })
let blob = new Blob([csvContentClean], { type: 'application/csv' })
let newCSVFile: File = this.blobToFile(blob, this.filename + '.csv')
this.uploader.addToQueue([newCSVFile])
}

View File

@ -18,4 +18,4 @@ In any case, you must not make any such use of this software as to develop softw
UNLESS EXPRESSLY AGREED OTHERWISE, 4GL APPS PROVIDES THIS SOFTWARE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, AND IN NO EVENT AND UNDER NO LEGAL THEORY, SHALL 4GL APPS BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING FROM USE OR INABILITY TO USE THIS SOFTWARE.
`
`

View File

@ -1,6 +1,6 @@
{
"name": "dcfrontend",
"version": "6.6.1",
"version": "6.6.2",
"description": "Data Controller",
"devDependencies": {
"@saithodev/semantic-release-gitea": "^2.1.0",