4 Replies - 378 Views - Last Post: 04 September 2013 - 07:10 AM Rate Topic: -----

#1 vasant_Gowda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 27-August 13

How to compare keys or columns of two dictionaries

Posted 03 September 2013 - 12:04 AM

Hi Friends,
My issue is, I have two map files and storing those two files in dictionary and comparing two columns and printing the result.......I don't know how to compare those items....Comprable items will be the values of first dictionary and keys of another dictionary..........
Is This A Good Question/Topic? 0
  • +

Replies To: How to compare keys or columns of two dictionaries

#2 vasant_Gowda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 27-August 13

Re: How to compare keys or columns of two dictionaries

Posted 03 September 2013 - 01:39 AM

Hi Friends,

My issue is, I have 2 map files and reading these two files and store it in dictionary I got the output as


=================================================================================

Single Legend:
Standard_Animator: blue, 3f7fff, 00bfff, 3fffbf, green, bfff3f, ffbf00, ff7f00, red

LegendName -- Colorlist:
STANDARD_ANIMATOR -- BLUE,3F7FFF,00BFFF,3FFFBF,GREEN,BFFF3F,FFBF00,FF7F00,RED

Colors:
['BLUE', '3F7FFF', '00BFFF', '3FFFBF', 'GREEN', 'BFFF3F', 'FFBF00', 'FF7F00', 'RED']

Single Legend:
Extended_Animator: LightGray, blue,3f7fff,00bfff,3fffbf,green,bfff3f,ffbf00,ff7f00,red, Magenta

LegendName -- Colorlist:
EXTENDED_ANIMATOR -- LIGHTGRAY,BLUE,3F7FFF,00BFFF,3FFFBF,GREEN,BFFF3F,FFBF00,FF7F00,RED,MAGENTA

Colors:
['LIGHTGRAY', 'BLUE', '3F7FFF', '00BFFF', '3FFFBF', 'GREEN', 'BFFF3F', 'FFBF00', 'FF7F00', 'RED', 'MAGENTA']

LegendDict:
{'EXTENDED_ANIMATOR': ['LIGHTGRAY', 'BLUE', '3F7FFF', '00BFFF', '3FFFBF', 'GREEN', 'BFFF3F', 'FFBF00', 'FF7F00', 'RED', 'MAGENTA'], 'STANDARD_ANIMATOR': ['BLUE', '3F7FFF', '00BFFF', '3FFFBF', 'GREEN', 'BFFF3F', 'FFBF00', 'FF7F00', 'RED']}


=================================================================================

EXTENDED_ANIMATOR
11 Colors defined in Legend: EXTENDED_ANIMATOR
LIGHTGRAY
BLUE
3F7FFF
00BFFF
3FFFBF
GREEN
BFFF3F
FFBF00
FF7F00
RED
MAGENTA

STANDARD_ANIMATOR
9 Colors defined in Legend: STANDARD_ANIMATOR
BLUE
3F7FFF
00BFFF
3FFFBF
GREEN
BFFF3F
FFBF00
FF7F00
RED


=================================================================================


But I expect the output to be all in hexadecimal..I got how to read and print the output by writing the code


for cols in colorfile:
cols = string.upper(cols)
h = cols.split(' ')
cname = h[0]
chex = h[1]
colordict[cname] = chex
for legendname,colorlist in legenddict.items():
for color in colorlist:
if cname in color:
print chex

but what I got the output is

0000FF
0000FF
808080
008000
008000
D3D3D3
FF00FF
FF0000
FF0000


BUT I expect SHOULD BE IN THE FORMAT


EXTENDED_ANIMATOR
11 Colors defined in Legend: EXTENDED_ANIMATOR
D3D3D3
0000FF
3F7FFF
00BFFF
3FFFBF
008000
BFFF3F
FFBF00
FF7F00
FF0000
FF00FF

STANDARD_ANIMATOR
9 Colors defined in Legend: STANDARD_ANIMATOR
0000FF
3F7FFF
00BFFF
3FFFBF
008000
BFFF3F
FFBF00
FF7F00
FF0000

i.e all colors should be in hexadecimal digit how to do that
Was This Post Helpful? 0
  • +
  • -

#3 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 541
  • View blog
  • Posts: 1,708
  • Joined: 08-November 08

Re: How to compare keys or columns of two dictionaries

Posted 03 September 2013 - 06:50 AM

The values you provided from the output you're getting are in hexadecimal. Could you please clarify what isn't working to your satisfaction and why?
Was This Post Helpful? 0
  • +
  • -

#4 vasant_Gowda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 27-August 13

Re: How to compare keys or columns of two dictionaries

Posted 03 September 2013 - 08:24 PM

I want the output to be all in hexadecimal format i.e in the following format

EXTENDED_ANIMATOR
11 Colors defined in Legend: EXTENDED_ANIMATOR
D3D3D3
0000FF
3F7FFF
00BFFF
3FFFBF
008000
BFFF3F
FFBF00
FF7F00
FF0000
FF00FF

STANDARD_ANIMATOR
9 Colors defined in Legend: STANDARD_ANIMATOR
0000FF
3F7FFF
00BFFF
3FFFBF
008000
BFFF3F
FFBF00
FF7F00
FF0000


i.e all color names should be converted to hexcode
Was This Post Helpful? 0
  • +
  • -

#5 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 541
  • View blog
  • Posts: 1,708
  • Joined: 08-November 08

Re: How to compare keys or columns of two dictionaries

Posted 04 September 2013 - 07:10 AM

Oh, I see it now. Well, your code won't know what "blue", "lightgray", etc. are until and unless you define it. You can do this with a dictionary that maps the word representation of the color to the hex color code you want it to represent.

This post has been edited by Valek: 04 September 2013 - 07:10 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1