| Revision 556,
832 bytes
checked in by jdalbey, 6 years ago
(diff) |
|
Ver 0.1 of Graphic Traffic Events Creator.
|
| Rev | Line | |
|---|
| 1 | import json, sys |
|---|
| 2 | # Read 2 filenames from command line |
|---|
| 3 | # Output to stdout features in file2 not in file1 |
|---|
| 4 | |
|---|
| 5 | if len(sys.argv) == 1: |
|---|
| 6 | print "Must provide 2 command line arguments" |
|---|
| 7 | print 'Number of arguments:', len(sys.argv)-1 |
|---|
| 8 | exit |
|---|
| 9 | |
|---|
| 10 | with open(sys.argv[1], "r") as read_file: |
|---|
| 11 | j = json.load(read_file) |
|---|
| 12 | |
|---|
| 13 | features1 = j["features"] |
|---|
| 14 | |
|---|
| 15 | # Create a set of ID's from first file of features |
|---|
| 16 | alpha = set() |
|---|
| 17 | for f in features1: |
|---|
| 18 | alpha.add(f["id"]); |
|---|
| 19 | |
|---|
| 20 | with open(sys.argv[2], "r") as read_file: |
|---|
| 21 | j = json.load(read_file) |
|---|
| 22 | |
|---|
| 23 | features2 = j["features"] |
|---|
| 24 | |
|---|
| 25 | # Lookup each feature ID from file2 in set |
|---|
| 26 | bravo = [] |
|---|
| 27 | for f in features2: |
|---|
| 28 | target = f["id"] |
|---|
| 29 | if target not in alpha: |
|---|
| 30 | bravo.append(target); |
|---|
| 31 | |
|---|
| 32 | # bravo contains items in dat2 not in dat1 |
|---|
| 33 | for b in bravo: |
|---|
| 34 | print b |
|---|
| 35 | |
|---|
| 36 | # Note features dicts are saved for future use |
|---|
Note: See
TracBrowser
for help on using the repository browser.