From 228cc768710509732c4a8ce58a97e7581720b9bd Mon Sep 17 00:00:00 2001 From: Alex Bourret Date: Wed, 18 Feb 2026 12:04:01 +0100 Subject: [PATCH 1/4] adding second csv decoding method + sniffing dialect --- python-lib/dku_utils.py | 43 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/python-lib/dku_utils.py b/python-lib/dku_utils.py index 430875a..3b65fa4 100644 --- a/python-lib/dku_utils.py +++ b/python-lib/dku_utils.py @@ -171,9 +171,50 @@ def decode_csv_data(data): import io json_data = None data = decode_bytes(data) + logger.info("Sniffing potential csv data") try: - reader = csv.DictReader(io.StringIO(data)) + sniffer = csv.Sniffer() + dialect = sniffer.sniff(data) + logger.info( + "Decoding CSV method 1 with delim='{}', dbl='{}', esc='{}', lnt='{}', qtchr='{}', qtng='{}', skip='{}'".format( + dialect.delimiter, + dialect.doublequote, + dialect.escapechar, + dialect.lineterminator, + dialect.quotechar, + dialect.quoting, + dialect.skipinitialspace + ) + ) + except Exception as error: + logger.error("Could not sniff csv dialect. Error={}".format(error)) + dialect = "excel" + try: + reader = csv.DictReader( + io.StringIO(data), + dialect=dialect + ) json_data = list(reader) + except Exception as error: + logger.error("Could not extract csv data. Error={}. Trying method 2.".format(error)) + json_data = decode_csv_data_m2(data, dialect) + return json_data + + +def decode_csv_data_m2(data, dialect): + import csv + json_data = None + try: + json_data = [] + headers = [] + for row in csv.reader(data.splitlines(), dialect=dialect): + if not headers: + headers = row + else: + output_row = {} + for header, item in zip(headers, row): + output_row[header] = item + json_data.append(output_row) except Exception as error: logger.error("Could not extract csv data. Error={}".format(error)) json_data = data From f6c0db6013453cb23026cf24d52a7830dd3f9bdc Mon Sep 17 00:00:00 2001 From: Alex Bourret Date: Wed, 18 Feb 2026 12:04:11 +0100 Subject: [PATCH 2/4] v1.2.7 --- plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.json b/plugin.json index 9f69c33..afb4273 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "id": "api-connect", - "version": "1.2.6", + "version": "1.2.7", "meta": { "label": "API Connect", "description": "Retrieve data from any REST API", From 309162ea000ef4cfaf7a5751e755ac306502d588 Mon Sep 17 00:00:00 2001 From: Alex Bourret Date: Wed, 18 Feb 2026 12:04:18 +0100 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f08acf9..a815c09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [Version 1.2.7](https://github.com/dataiku/dss-plugin-api-connect/releases/tag/v1.2.7) - Feature - 2026-02-18 + +- Detecting dialect for better csv decoding + ## [Version 1.2.6](https://github.com/dataiku/dss-plugin-api-connect/releases/tag/v1.2.6) - Feature - 2025-09-24 - Add "recipesCategory" parameter so that the API connect recipe is categorized as a Visual recipe in the right hand panel From 51aa4d390ece4562be757a3babcb873c1dd55908 Mon Sep 17 00:00:00 2001 From: Alex Bourret Date: Wed, 18 Feb 2026 12:04:25 +0100 Subject: [PATCH 4/4] beta.1 --- python-lib/dku_constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-lib/dku_constants.py b/python-lib/dku_constants.py index 623c844..d16088e 100644 --- a/python-lib/dku_constants.py +++ b/python-lib/dku_constants.py @@ -2,6 +2,6 @@ class DKUConstants(object): API_RESPONSE_KEY = "api_response" FORBIDDEN_KEYS = ["token", "password", "api_key_value", "secure_token"] FORM_DATA_BODY_FORMAT = "FORM_DATA" - PLUGIN_VERSION = "1.2.5" + PLUGIN_VERSION = "1.2.7-beta.1" RAW_BODY_FORMAT = "RAW" REPONSE_ERROR_KEY = "dku_error"