Converting vCard or vcf to csv

Here’s a small scenario that converts the VCF string with an empty FN: key and filters that out from the final CSV. YOu can copy this to your clipboard and paste it into a new scenario.

Note that your CSV will just have 2 columns, the key and the value. If you want to actually convert each key into a column name and then each value into a component of one row that’s a completely different operation and the results of the text parse will need to be restructured into a row using some data structure manipulation.

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 1,
                    "module": "util:SetVariables",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "variables": [
                            {
                                "name": "vcf2.1string",
                                "value": "BEGIN:VCARD\nVERSION:2.1\nN:Gump;Forrest;;Mr.\nFN:\nORG:Bubba Gump Shrimp Co.\nTITLE:Shrimp Man\nPHOTO;GIF:http://www.example.com/dir_photos/my_photo.gif\nTEL;WORK;VOICE:(111) 555-1212\nTEL;HOME;VOICE:(404) 555-1212\nADR;WORK;PREF:;;100 Waters Edge;Baytown;LA;30314;United States of America\nLABEL;WORK;PREF;ENCODING#QUOTED-PRINTABLE;CHARSET#UTF-8:100 Waters Edge#0D#\n #0ABaytown\\, LA 30314#0D#0AUnited States of America\nADR;HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America\nLABEL;HOME;ENCODING#QUOTED-PRINTABLE;CHARSET#UTF-8:42 Plantation St.#0D#0A#\n Baytown, LA 30314#0D#0AUnited States of America\nEMAIL:forrestgump@example.com\nREV:20080424T195243Z\nEND:VCARD"
                            }
                        ],
                        "scope": "roundtrip"
                    },
                    "metadata": {
                        "designer": {
                            "x": 0,
                            "y": 0
                        },
                        "restore": {
                            "expect": {
                                "variables": {
                                    "items": [
                                        null
                                    ]
                                },
                                "scope": {
                                    "label": "One cycle"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "variables",
                                "type": "array",
                                "label": "Variables",
                                "spec": [
                                    {
                                        "name": "name",
                                        "label": "Variable name",
                                        "type": "text",
                                        "required": true
                                    },
                                    {
                                        "name": "value",
                                        "label": "Variable value",
                                        "type": "any"
                                    }
                                ]
                            },
                            {
                                "name": "scope",
                                "type": "select",
                                "label": "Variable lifetime",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "roundtrip",
                                        "execution"
                                    ]
                                }
                            }
                        ],
                        "interface": [
                            {
                                "name": "vcf2.1string",
                                "label": "vcf2.1string",
                                "type": "any"
                            }
                        ]
                    }
                },
                {
                    "id": 2,
                    "module": "regexp:GetElementsFromText",
                    "version": 1,
                    "parameters": {
                        "continueWhenNoRes": false
                    },
                    "mapper": {
                        "pattern": "##key_value_pairs",
                        "text": "{{1.`vcf2.1string`}}",
                        "delimiter": ":",
                        "strictMatchPerLine": true,
                        "specialCharsPattern": ""
                    },
                    "metadata": {
                        "designer": {
                            "x": 262,
                            "y": -1
                        },
                        "restore": {
                            "expect": {
                                "pattern": {
                                    "label": "Pair of key:value"
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "continueWhenNoRes",
                                "type": "boolean",
                                "label": "Continue the execution of the route even if the module finds no matches",
                                "required": true
                            }
                        ],
                        "expect": [
                            {
                                "name": "pattern",
                                "type": "select",
                                "label": "Pattern",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "##emails",
                                        "##html_tags",
                                        "##http_urls",
                                        "##ftp_urls",
                                        "##telephone_numbers",
                                        "##ipv4",
                                        "##ipv6",
                                        "##emoji",
                                        "##key_value_pairs"
                                    ]
                                }
                            },
                            {
                                "name": "text",
                                "type": "text",
                                "label": "Text",
                                "required": true
                            },
                            {
                                "name": "delimiter",
                                "type": "text",
                                "label": "Delimiter",
                                "required": true
                            },
                            {
                                "name": "strictMatchPerLine",
                                "type": "boolean",
                                "label": "Only first pair per line",
                                "required": true
                            },
                            {
                                "name": "specialCharsPattern",
                                "type": "text",
                                "label": "Special characters in the pattern"
                            }
                        ],
                        "interface": [
                            {
                                "name": "match",
                                "label": "Match",
                                "type": "any"
                            },
                            {
                                "name": "key",
                                "label": "Key",
                                "type": "text"
                            },
                            {
                                "name": "value",
                                "label": "Value",
                                "type": "text"
                            }
                        ]
                    }
                },
                {
                    "id": 4,
                    "module": "csv:CreateAggregator",
                    "version": 1,
                    "parameters": {
                        "includeHeaders": true,
                        "delimiterType": "other",
                        "newlineType": "LF",
                        "delimiter": ",",
                        "feeder": 2
                    },
                    "filter": {
                        "name": "for all non empty values",
                        "conditions": [
                            [
                                {
                                    "a": "{{2.value}}",
                                    "o": "text:notequal",
                                    "b": "{{emptystring}}"
                                }
                            ]
                        ]
                    },
                    "mapper": {
                        "key": "{{2.key}}",
                        "value": "{{2.value}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 602,
                            "y": -4,
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {
                            "parameters": {
                                "delimiterType": {
                                    "label": "Other"
                                },
                                "newlineType": {
                                    "label": "LF"
                                }
                            },
                            "extra": {
                                "feeder": {
                                    "label": "Text parser - Match elements [2]"
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "includeHeaders",
                                "type": "boolean",
                                "label": "Include headers in the first row",
                                "required": true
                            },
                            {
                                "name": "delimiterType",
                                "type": "select",
                                "label": "Delimiter",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        ",",
                                        "\t",
                                        "other"
                                    ]
                                }
                            },
                            {
                                "name": "newlineType",
                                "type": "select",
                                "label": "Newline",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "LF",
                                        "CRLF"
                                    ]
                                }
                            },
                            {
                                "name": "delimiter",
                                "type": "text",
                                "label": "Delimiter character",
                                "validate": {
                                    "max": 1,
                                    "min": 1
                                },
                                "required": true
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}
2 Likes