This post is a follow up to the post made a few weeks ago: Phantombuster to Snov.io Zap question.
What I am trying to do is that when a prospect that is scraped using Phantombuster does not have an email that is found, I want to remove that prospect entirely from the data set. That way, the emails that are scraped match the prospects they belong to and can be imported into Snovio.
The data I am getting from the Phantombuster scrape looks ok. Here is how I am mapping the keys from the Phantombuster output to the Run Javascript step:
When I apply the following JavaScript code, it ends up muddling the information.
// get Input Data field names
let keys = Object.keys(inputData)
let data = ];
console.log(inputData);
// loop through each Input Data field
for (let key of keys) {
// split the contents of each Input Data field on the commas into an array
let li = inputDataakey].split(",");
for (let i=0; i<li.length; i++) {
if (typeof dataai] === "undefined") dataai] = {};
dataai][key] = li i];
// add a record number (in case we want to break the fork/loop with a Filter)
dataai].recordNumber = i+1;
}
}
for (var i=0; i < data.length; i++) {
if (dataai]["Email"] == '' || !dataai]["Email"]) dataai] = null;
}
data = data.filter(function (el) {
return el != null;
});
// preview the whole data structure in the output
console.log(data);
// output the data
output = data;
When Phantombuster cannot find an email for a particular prospect, it assigns that key a blank string. So when the Phantom runs it scrapes 10 prospects and usually there are only 4 or 5 emails that are found.
Here is the corresponding console log for an example run:
Not really sure what is happening here, can anyone from