CSV help - Need to comma separate 2 columns into one cell

I need a way to combine two columns into one with a comma in between, only if both columns contain data. Else just insert into the cell whatever one has data.

Example:
Needs a comma as both cells have data: TagA, TagB
Doesn’t need a comma as TagB cell is empty: TagA
Doesn’t need a comma as TagA cell is empty: TagB

I tried to use ChatGPT and Make Ai but not having much luck. Here’s the Text aggregator module where I want to set this, but its output when 2 columns have data is the first tag.

First attempt:

Second attempt:

Welcome to the Make community!

To allow others to assist you with your scenario, please provide the following:

1. Scenario Blueprint

Please export the scenario blueprint. Providing your scenario blueprint file will allow others to quickly recreate and see how you have set up the mappings in each module, and also allows us take screenshots or provide module exports of any solutions we have for you in return - this would greatly benefit you in implementing our suggestions as you can simply paste module exports back into your scenario editor!

To export your scenario blueprint, click the three dots at the bottom of the editor then choose ‘Export Blueprint’.

You can upload the file here by clicking on this button:

2. Output Bundles of Modules

Please provide the output bundles of each of the relevant modules (21 & 39) by running the scenario (you can also get this without re-running your scenario from the History tab).

Click on the white speech bubbles on the top-right of each module and select “Download input/output bundles”.

A. Upload as a Text File

Save each bundle contents in a plain text editor (without formatting) as a bundle.txt file.

You can upload the file here by clicking on this button:

B. Insert as Formatted Code Block

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles.
These are the two ways to format text so that it won’t be modified by the forum:

  • Method 1: Type code block manually

    Add three backticks ``` before and after the content/bundle, like this:

    ```
    content goes here
    ```

  • Method 2. Highlight and click the format button in the editor

Providing the input/output bundles will allow others to replicate what is going on in the scenario, especially if there are complex data structures (nested arrays and collections) or if external services are involved.

Sharing these details will make it easier for others to assist you.

Hi there,

Here is the logic for the Text aggregator module:

{{21.col6 & 21.col7}}

It’s been modified to just output both tags with a space between each, its not ideal as it would be treated as one tag. I’m struggling to insert a comma without it being treated as a column separator (which happens currently).

Here is the current blueprint:

custom-csv-sq-csv-blueprint.json (68.0 KB)

Any luck figuring this one out?

That’s not enough information to answer your question. Please follow the above instructions to provide the output bundles of 21 & 39.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Here’s the output files:
output-21.txt (13.0 KB)
output-39.txt (3.8 KB)

Latest blueprint:
blueprint (2).json (68.1 KB)

Looks like you can do something like this:

,,PHYSICAL,Buy,,{{21.col4}} ({{21.col3}}) {{21.col5}},,,,,,,,,,,,,,,{{if(21.col11 < 0.1; 0.1; 21.col11)}},,,{{21.col10}},{{21.col3}},"{{join(remove(add(emptyarray; 21.col6; 21.col7); emptystring); ",")}}",,,,,,{{21.col14}}

  • add both tags into an array
  • remove empty values from array
  • join the array by comma
  • wrap the “cell” in double quotes because there might be a comma in there

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

1 Like

Hey there, looks like it works!

I’m still in testing mode at the moment but it looks like the its outputting the tags as intended.

No problem, really glad I could help! Thank you for providing all the requested information — that allowed me to come to a solution quickly.

1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.