1

So i'm using python and I have an email dict being pulled from a large .csv column file where some values might have multiple values. I'm implementing this column into a vertex for a graphing database so order is key. I am using Gremlin API.

Here's what I have for my code:

contact_email_name_map = defaultdict()

for i in range(len(contact_email)):
    contact_email_name_map[contact_email[i]] = account_name[i]  

for key, value in contact_email_name_map.items():
    print(key, "-------------------", value)

what happens now:

output:
[email protected]
[email protected]
[email protected];[email protected]
[email protected]

what I would like to happen:

output:
[email protected]
[email protected]

[email protected] 
[email protected]

[email protected]

Does anyone know how to solve this issue?

I hope this makes sense

1 Answer 1

1

You can split on the delimiter:

for key, value in contact_email_name_map.items():
    for email in key.split(";"):
        print(email, "-------------------", value)
Sign up to request clarification or add additional context in comments.

2 Comments

Unfortunately that didn't help, since the email data frame is the key in this default dict, not the value
@JBlock well then just swap key and value in the loop. Will edit to show.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.