Heyy Everyone… I am trying to convert a vcf (Contact file) to csv in make. Any suggestions to do that within make?
What happens when you do
toString(data)
on the file data after you’ve downloaded it?
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.
Save each bundle contents in your text editor as a bundle.txt
file, and upload it here into this discussion thread.
Uploading them here will look like this:
module-1-input-bundle.txt (12.3 KB)
module-1-output-bundle.txt (12.3 KB)
B.
If you are unable to upload files on this forum, alternatively you can paste the formatted bundles 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:
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!
with toString function i receive this data :
and with text parser using key: value, i receive some details but not getting empty fields
Looks like you can use a Text Parser Match Pattern module since it’s almost plain text format.
Not Match Elements.
But problem is when i use online converter tools in csv file, i receive empty fields/columns as well. Is there something that can be done using tools> text encoder module?
Why not put in a filter on the path after the text parser to check for empty values coming in from the text parser bundles? That way you can evaluate which fields go into the converter tools module?
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
}
}
@alex.newpath Thanks for this solution…
Does it have an API to use it in automation?
Hi Alex, This sounds great. Excuse my ignorance but what do I do with this file? I copied it and saved as a JSON file and in a new Scenario I imported blueprint. I saw a message saying it imported but the scenario remains empty. Should there be some modules added or do they need adding first?? Thanks!
Module Export (NOT Blueprint Export)
You can copy and paste that module export directly into your scenario’s canvas. This will paste the modules.
-
Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
-
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.
-
Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.
I’ve tested this although my requirement is a little different and I’m just not sure how to map fields from the inbound vCard to fields in a database
i’m not looking for a CSV file although I do need to somehow get the scenario to a point where I can map each field in the vCard to fields in my database.
I think I’m getting in a bit of a mess
My scenario aims to use a MailHook to recieve an email containing an attached vCard. I then filter out all other attachments of images that are not of a mimetype vCard. I somehow need to extract the vCard text content. From this topic I’ve managed to define variables for each element of the vCard.
I just cant see how I am able to then map each key:value to different fields in the database.
Stuck so any pearls of wisdom would be much appreciated.
How about posting a new thread then? I suggest you share the output bundles just before the step where you are trying to map into your database in the new thread so we can help you.