[Tutor] dictionary of lists

2015-06-03 Thread Chris Stinemetz
I am trying to create a dictionary of lists as I read a file. I envision it looking like: {key: [float_type],[string_type]} For the first item in the list I am trying to add the value to the existing value where the key matches but I am getting the following error: Resetting execution engine Runn

Re: [Tutor] dictionary of lists

2015-06-03 Thread Chris Stinemetz
> >> Resetting execution engine >> Running >> C:\Users\cs062x\Desktop\python\projects\PanHandle\PanHandle\PanHandle.py >> The Python REPL process has exited > > > That's slightly unusual. How are you running this? > I am running it with Microsoft Visual Studio Community 2013 using Python Tools for

Re: [Tutor] dictionary of lists

2015-06-04 Thread Chris Stinemetz
On Thu, Jun 4, 2015 at 2:30 AM, Peter Otten <__pete...@web.de> wrote: > Chris Stinemetz wrote: > >> Although I am certain it is not very efficient I was able to >> accomplish what I wanted with the following code I wrote: >> >> import os >> import pprin

[Tutor] updating a dictionary

2015-02-19 Thread Chris Stinemetz
Hello List, I have a dictionary that I would like to update/add rows to it as I read a file line by line. The dictionary format looks like: format = {'Cell': '','7':'','8':'','9':'','2':''} For each line read in I would simply like to check to see if a Cell key;value exists and if it does updat

Re: [Tutor] updating a dictionary

2015-02-19 Thread Chris Stinemetz
> > > > > Other than the minor tweaks I've suggested I'm not sure what your problem > is? I think we need to see the data to understand the issue. ​Here is a sample of the input data, it is tab delimited and I chopped it down for example purposes: ​ KSL03502_7A_1 11.5921 KSL03502_7B_1 46.4997 K

Re: [Tutor] updating a dictionary

2015-02-20 Thread Chris Stinemetz
I am getting closer. I think I have figured out the logic. I just have a quick question. How do you access key:values in a nested dictionary? MOL02997_C': [{'2': '0', '7': '0', '8': '0', '9': '0'}]} say I want to access the key:value 8:0 print dict['MOL02997_C']['8'] doesn't seem to work. Thank

Re: [Tutor] updating a dictionary

2015-02-20 Thread Chris Stinemetz
On Fri, Feb 20, 2015 at 4:51 PM, Mark Lawrence wrote: > On 20/02/2015 17:56, Chris Stinemetz wrote: > > Please don't top post as it makes long threads difficult if not impossible > to follow, thanks. > > I am getting closer. I think I have figured out the logic. I just h

[Tutor] append value to dictionary key

2015-03-06 Thread Chris Stinemetz
I would like to append a value to a dictionary key where there is already a value. Something like the below: d = {'name': {'2': 0.0, '7': 10.0, '8': 0.0, '9': 0.0}} append 10 to d['name']['2'] d = {'name': {'2': 0.0,10, '7': 10.0, '8': 0.0, '9': 0.0}} When I try to this I get the following error: