Converting strings into Bundles

Hey Community!
I’m creating an automation that pulls expense reports on expensify, to send missing receipt reports to send automatically to employees. I’m able to pull the data I need and convert it into a string. But now I need to convert the long string into a data type that I can run through and iterator to break it up into bundles.

Basically what I want is each transaction to be in a different bundle, I will then filter out the transactions with receipt ID’s and then create arrays grouped by the User’s email to send out the emails. Would love to hear if there is a way to convert the string:

Welcome to the Make community!

You can use a Text Parser “Match Pattern” module.

If you would like some help creating the pattern, please provide the text as text, not a screenshot of it because we cannot copy text from screenshots.


If you need further assistance, please provide the following:

Please provide the output bundles of the modules by running the scenario, then click the white speech bubble on the top-right of each module and select “Download output bundles”.
Screenshot_2023-10-06_141025

A.

Save the bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.
Uploading it here will look like this:

bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted output bundle in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the 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!

2 Likes

Hello,

Thank you for letting me know. Below is the original text string, it wouldn’t allow me to upload a .txt file. I’ll try out the Text parser in the mean time. Essentially I would like the long string to be able to broken out into different bundles.

[
    {
        "data": "    Travel AMEX Plat 01272024 - 02262024\n    Dave AMEX BLK 01272024 - 02262024\n    Julie AMEX Plat 01272024 - 02262024\n    Justin AMEX BLK 01272024 - 02262024\n    Kim AMEX Plat 01272024 - 02262024\n    Jasa AMEX Plat 01272024 - 02262024\n    Nick AMEX Plat 01272024 - 02262024\n    Leta AMEX Plat 01272024 - 02262024\n    Tom AMEX Plat 01272024 - 02262024\n    Carolina AMEX Plat 01272024 - 02262024\n    Jason AMEX BLK 01272024 - 02262024\n    MB AMEX Plat 01272024 - 02262024\n    Lisa AMEX Plat 01272024 - 02262024\n    Bethany AMEX Plat 01272024 - 02262024\n    New Report\n"
    }
]

Welcome to the Make community!

You can use a Text Parser “Match Pattern” module with this regular expression pattern

(?<name>\w+)\s+?(?<card>(?:AMEX|VISA)\s\w+)\s(?<from>\d+?)\D+(?<to>\d+)

Regex test: https://regex101.com/r/bsno78

Important Info

  • :warning: Global match must be set to YES!

Screenshot

Output


For more information, see Text Parser in the Make Help Center:

Match Pattern
The Match pattern module enables you to find and extract string elements matching a search pattern from a given text. The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

Hope this helps!

3 Likes

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV to paste in the canvas.

  3. Click on each imported module and save it. You may need to remap some variables.

Modules JSON Export

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 10,
                    "module": "regexp:Parser",
                    "version": 1,
                    "parameters": {
                        "pattern": "(?<name>\\w+)\\s+?(?<card>(?:AMEX|VISA)\\s\\w+)\\s(?<from>\\d+?)\\D+(?<to>\\d+)",
                        "global": true,
                        "sensitive": true,
                        "multiline": false,
                        "singleline": false,
                        "continueWhenNoRes": false,
                        "ignoreInfiniteLoopsWhenGlobal": false
                    },
                    "mapper": {
                        "text": "{{9.value}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 406,
                            "y": -372,
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {
                            "parameters": {
                                "sensitive": {
                                    "collapsed": true
                                },
                                "multiline": {
                                    "collapsed": true
                                },
                                "singleline": {
                                    "collapsed": true
                                },
                                "continueWhenNoRes": {
                                    "collapsed": true
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "pattern",
                                "type": "text",
                                "label": "Pattern",
                                "required": true
                            },
                            {
                                "name": "global",
                                "type": "boolean",
                                "label": "Global match",
                                "required": true
                            },
                            {
                                "name": "sensitive",
                                "type": "boolean",
                                "label": "Case sensitive",
                                "required": true
                            },
                            {
                                "name": "multiline",
                                "type": "boolean",
                                "label": "Multiline",
                                "required": true
                            },
                            {
                                "name": "singleline",
                                "type": "boolean",
                                "label": "Singleline",
                                "required": true
                            },
                            {
                                "name": "continueWhenNoRes",
                                "type": "boolean",
                                "label": "Continue the execution of the route even if the module finds no matches",
                                "required": true
                            },
                            {
                                "name": "ignoreInfiniteLoopsWhenGlobal",
                                "type": "boolean",
                                "label": "Ignore errors when there is an infinite search loop",
                                "required": true
                            }
                        ],
                        "expect": [
                            {
                                "name": "text",
                                "type": "text",
                                "label": "Text"
                            }
                        ],
                        "interface": [
                            {
                                "type": "text",
                                "name": "name",
                                "label": "name"
                            },
                            {
                                "type": "text",
                                "name": "card",
                                "label": "card"
                            },
                            {
                                "type": "text",
                                "name": "from",
                                "label": "from"
                            },
                            {
                                "type": "text",
                                "name": "to",
                                "label": "to"
                            },
                            {
                                "type": "uinteger",
                                "name": "i",
                                "label": "i"
                            },
                            {
                                "type": "any",
                                "name": "__IMTMATCH__",
                                "label": "Fallback Match"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}
3 Likes