How to deal with multi dimensional array

Hi,

I want to extract data from HTML table. After I used ‘Get content from HTML table’, I got this array of collection of array.

Then after I applied map() function I got the multi-dimensional array like this:
스크린샷 2024-08-15 025733

I learned many use cases from Make academy, so I knew how to get necessary data from ‘array of collection’, but, I couldn’t figure out how to deal with these multi-dimensional array.

For example, how can I find second sub-array for that the first array is ‘time?’
or can I convert sub-array into collection so that I can use get and map functions?

Great question @s.ho; dealing with arrays and collections in Make drives me bonkers at times.

I’ve not directly used the extract data from HTML tables since that’s not a typical medium for me. However, in looking at the first array, I notice the headers array.

Does that headers array align with column 1 place, col 2 time, …, col 8 price?

If so, then you know what to grab from the second array.

For example, we want the persons count, which per the headers array is position 3, then we’d last(get(marray; 3))

The last works because it’s returning the last array value which is 2.

In sharing your blueprint, I can help further since I’d have something tangible to work with.

Hi, thank you for the quick response.

I think I can get the necessary data by using the exact col & row like you gave the example because position of data in the table are always fixed.

But I just want to learn how to find data using search keyword from multi-dimensional array like using get() and map() from array of collections.

Welcome to the Make community!

If you need further assistance, please provide the following:

Please provide the output bundles of the modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.

A. Upload as Text File

Save each bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

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 even if they do not use the external service.

This will allow others to better assist you. Thanks!

@samliew

Hi, this is my data extracted from HTML table.

[
    {
        "marray": [
            [
                "place",
                "Party Place"
            ],
            [
                "time",
                "2024/07/30 14:00-18:00"
            ],
            [
                "persons",
                "2"
            ],
            [
                "option",
                "parking"
            ],
            [
                "requirement",
                ""
            ],
            [
                "name",
                "Jane"
            ],
            [
                "payment",
                "\n\n                                        credit card\n\n                                  "
            ],
            [
                "price",
                "45,000"
            ]
        ]
    }
]

Hello @s.ho, I’m not sure how to use map in this case, because map is intended for keys and our column name is in first value.

See attached for my being curious to build a simple JSON to parse the data, but know my sharing is not efficient.

This solution does not work for when there’s more than one value entry.

blueprint (2).json (28.9 KB)

2 Likes

thank you so much for your solution. Now I can understand I can make it simple for table array like using map for collections.

I this case, I would use combination of last and get for array, but I would try to learn and use this solution for the next applications.