'Remove duplicate in key-value pattern

Hi I have an input which consist of duplicates.

"Jacob":56002
"Mark":1002
"Jacob":56002
"Jacob":1001
"Mark":1002

Desired Output:

"Jacob":56002
"Jacob":1001
"Mark":1002


Solution 1:[1]

Load the file into python, split lines, and then dedup.

data = """
"Jacob":56002
"Mark":1002
"Jacob":56002
"Jacob":1001
"Mark":1002
"""

spl = data.split('\n')
set([x.strip() for x in spl if x])

Out[46]: {'"Jacob":1001', '"Jacob":56002', '"Mark":1002'}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nathan Getty