This is what I could to with Python. Any way to this in EasyMorph?
import json
Column mapping based on schema
column_names = [
"status", "id", "category_id", "active", "main_category",
"images", "product_name_en", "related_items", "product_long_description_en",
"brand", "mpn", "product_files", "document_link_name_en",
"product_name_edited_en", "product_short_description_en",
"tech_data_en", "composition_en", "brochures_data_sheets",
"rec_price", "volt_en", "country_of_origin", "hs_code",
"gtin", "weight", "meta_text_en", "product_feed",
"google_taxonomy", "supplier_part_number", "ai_snippet_en",
"ai_write_request", "source_language", "translation_requests",
"hide", "web_unit_en"
]
Sample data
data_array = [
"M", "31791", "0", "1", "",
[["M", "f24b65933296dju25b1f9c5e71efc1a86", "https://d7rh5s3nxmimagen_01.jpg"]],
"Kootector 12 x 23 mm", , "", "SBC", "P1249", , "", "", "", "", "",
, "12", "", "", "", "8427327258679", "", "", "", "", "", "", , , , "", ""
]
Convert array to dictionary
mapped_data = {}
for i, key in enumerate(column_names):
mapped_data[key] = data_array[i]
Handle nested images
if isinstance(mapped_data["images"], list) and mapped_data["images"]:
mapped_data["images"] = [
{"status": img[0], "id": img[1], "org": img[2]} for img in mapped_data["images"]
]
Convert product files (if needed)
if isinstance(mapped_data["product_files"], list) and mapped_data["product_files"]:
mapped_data["product_files"] = [
{"status": file[0], "id": file[1], "file": file[2]} for file in mapped_data["product_files"]
]
Print JSON output
print(json.dumps(mapped_data, indent=2))