From b3a166793d7c9cab9451d7f9c5ec2a2f4011471b Mon Sep 17 00:00:00 2001 From: UKDTOM Date: Tue, 30 Nov 2021 01:53:29 +0100 Subject: [PATCH] WIP, and fiex #418 --- .../modules/ExportTools/defs/def-Fields.json | 4 +- .../modules/ExportTools/scripts/csv.js | 8 +- .../modules/ExportTools/scripts/ethelper.js | 129 +++++++++--------- 3 files changed, 76 insertions(+), 65 deletions(-) diff --git a/src/components/modules/ExportTools/defs/def-Fields.json b/src/components/modules/ExportTools/defs/def-Fields.json index 99403d7..9ec174f 100644 --- a/src/components/modules/ExportTools/defs/def-Fields.json +++ b/src/components/modules/ExportTools/defs/def-Fields.json @@ -1233,7 +1233,7 @@ "TMDB ID": { "key": "$.Guid[*]", - "call": 1, + "call": 2, "type": "array", "subtype": "string", "subkey": "$.id", @@ -1242,7 +1242,7 @@ "TMDB Link": { "key": "$.Guid[*]", - "call": 1, + "call": 2, "type": "array", "subtype": "string", "subkey": "$.id", diff --git a/src/components/modules/ExportTools/scripts/csv.js b/src/components/modules/ExportTools/scripts/csv.js index a031809..3475c51 100644 --- a/src/components/modules/ExportTools/scripts/csv.js +++ b/src/components/modules/ExportTools/scripts/csv.js @@ -13,7 +13,13 @@ const csv = new class CSV { async addHeaderToTmp({ stream: stream, item: item}) { - const strHeader = item.join(wtconfig.get('ET.ColumnSep', ',')); + // Walk each item, and add Qualifier + let headerArray = []; + let x = 0; + for (x=0; x 0; } - // Set Qualifier function setQualifier( {str:str}) { + const validQ = ["`", "'", "\""]; log.silly(`etHelper (setQualifier): String is: ${str}`); + //str = str.replaceAll(wtconfig.get('ET.TextQualifierCSV', 'N/A'),``); + + //var count = str.indexOf(wtconfig.get('ET.TextQualifierCSV')) + if (str.indexOf(wtconfig.get('ET.TextQualifierCSV', 'N/A')) > 0) + { + let selectedQ; + + for(const val of validQ) { + if ( val != wtconfig.get('ET.TextQualifierCSV', 'N/A')) + { + selectedQ = val; + break; + } + } + + + + log.silly(`etHelper (setQualifier) string contained Qualifier`); + console.log('Ged 2-0 str now: ' + str) + console.log('Ged 2-1 str after: ' + str.replaceAll(wtconfig.get('ET.TextQualifierCSV'), selectedQ)) + + str = str.replaceAll(wtconfig.get('ET.TextQualifierCSV'), selectedQ); + + + console.log('Ged 2-2 str Now: ' + str) + //console.log('Ged 3-0 Count: ' + count) + + } if (wtconfig.get('ET.TextQualifierCSV', 'N/A') == '"') { str = `"${str}"` } - else if (wtconfig.get('ET.TextQualifierCSV', 'N/A') == wtconfig.get('ET.NotAvail', 'N/A')) - { - console.log('Ged 6 We got N/A') - } else { str = `${wtconfig.get('ET.TextQualifierCSV', 'N/A')}${str}${wtconfig.get('ET.TextQualifierCSV', 'N/A')}` @@ -48,31 +72,6 @@ function setQualifier( {str:str}) return str; } -/* -// Adds the String Qualifier if needed -function setStrSeperator( {str: str}) -{ - if ( wtconfig.get('ET.TextQualifierCSV') ) - { - if ( wtconfig.get('ET.TextQualifierCSV') != ' ') - { - log.silly(`etHelper (setStrSeperator): Returning: ${wtconfig.get('ET.TextQualifierCSV')}${str}${wtconfig.get('ET.TextQualifierCSV')}`); - return wtconfig.get('ET.TextQualifierCSV') + str + wtconfig.get('ET.TextQualifierCSV'); - } - else - { - log.silly(`etHelper (setStrSeperator) No sep, so returning ${str}`); - return str; } - } - else - { - log.error(`etHelper (setStrSeperator): UPS no qualifier, so returning nothing`); - } -} - */ - - - //#endregion const etHelper = new class ETHELPER { @@ -220,7 +219,9 @@ const etHelper = new class ETHELPER { } async postProcess( {name, val, title=""} ){ - log.silly(`ETHelper(postProcess): Val is: ${JSON.stringify(val)}`) + log.silly(`ETHelper(postProcess): Val is: ${JSON.stringify(val)}`); + log.silly(`ETHelper(postProcess): name is: ${name}`); + log.silly(`ETHelper(postProcess): title is: ${title}`); let retArray = []; let x, retVal, start, strStart, end, result; try { @@ -240,13 +241,13 @@ const etHelper = new class ETHELPER { } case "Part File": for (x=0; x