OpenAI GPT content loop CSV File

Hi @Tess ,

I have now solved it a little differently :see_no_evil: . First of all I have the following JS

let parsed = fileButton1.parsedValue;
if (parsed && Array.isArray(parsed) && parsed.length > 0) {
    let itemsArray = parsed[0]; // Da es eine zweidimensionale Struktur hat
    let transformedItems = itemsArray.map(item => {
        let [sku, descriptionStart] = item["SKU;HTML_description"].split(";");
        let descriptionExtra = item["__parsed_extra"].join("");
        let fullDescription = descriptionStart + descriptionExtra;

        return {
            SKU: sku,
            HTML_description: fullDescription
        };
    });

    return transformedItems;
} else {
    return "No valid data";
}

and from there I take the data fitting into the next JS and trigger the openAI API

let file_data = transformCSV.data

const promises = file_data.map((row) => {
  return daveQuery.trigger({
    additionalScope: {
      id: row.SKU,
      description: row.HTML_description,
    }
  });
});

return Promise.all(promises)

I could not have done it without your help :see_no_evil:, thank you so much :partying_face:

1 Like