Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion python-lib/dku_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
43 changes: 42 additions & 1 deletion python-lib/dku_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down