F
Felice
Guest
I have read data from a csv file containing many duplicate email addresses into a temp table. The format is essentially id, emailtype-description, email.
Here is an example of some data:
I want to dedupe them, but I don't want to do this randomly. I want to make sure that certain types take priority over others. For instance, some are marked with the type "email primary" and those should always remain, additional types take precedent over others, so "E-mail" will take precedent over "E-mail2".
I'd like to do in Progress code the equivalent of a custom sort of emailtype-description, then a de-dupe. That way I could define the sort order and then dedupe to retain the emails and the types by priority.
Is there a way to do this to my table in Progress? I want to sort first by uniqueid, then by emailtype-description, but I want a custom sort, not an alphabetical sort. What is the best approach?
Continue reading...
Here is an example of some data:
Code:
id emailtype-description email
1 E-Mail john@gmail.com
1 preferred E-mail john@gmail.com
2 2nd E-mail stacey@yahoo.com
2 preferred-Email sth@yahoo.com
2 family-email sth@yahoo.com
Code:
cInputFile = SUBSTITUTE(cDataDirectory, "Emails").
INPUT STREAM csv FROM VALUE(cInputFile).
IMPORT STREAM csv DELIMITER "," ^ NO-ERROR.
REPEAT TRANSACTION:
CREATE ttEmail.
IMPORT STREAM csv DELIMITER ","
ttEmail.uniqueid
ttEmail.emailTypeDescription
ttEmail.emailAddr
.
END.
INPUT STREAM csv CLOSE.
I want to dedupe them, but I don't want to do this randomly. I want to make sure that certain types take priority over others. For instance, some are marked with the type "email primary" and those should always remain, additional types take precedent over others, so "E-mail" will take precedent over "E-mail2".
I'd like to do in Progress code the equivalent of a custom sort of emailtype-description, then a de-dupe. That way I could define the sort order and then dedupe to retain the emails and the types by priority.
Is there a way to do this to my table in Progress? I want to sort first by uniqueid, then by emailtype-description, but I want a custom sort, not an alphabetical sort. What is the best approach?
Continue reading...