On Thu, Aug 7, 2008 at 12:42 AM, Shrutarshi Basu <[EMAIL PROTECTED]>wrote:
> If you're just going to be using numbers as dictionary keys, it might
> be simpler just to use a list structure. Dictionaries don't preserve
> order, so you'd need to write extra code if you ever need to iterate
> over it
If you're just going to be using numbers as dictionary keys, it might
be simpler just to use a list structure. Dictionaries don't preserve
order, so you'd need to write extra code if you ever need to iterate
over it in order. Since your code increments field everytime it gets a
new record you can j
"Alan Gauld" <[EMAIL PROTECTED]> wrote
index = float(the_line[-1])
dif_index = index - start_index
iindex[field] = dif_index
Here index is assigned to a floating point number.
Then it is indexed. Floats don't have indexes...
Just noticed the indexed vari
"Bryan Fodness" <[EMAIL PROTECTED]> wrote
i am filling a dictionary with a dictionary and my values for
isegment[field] are identical. i can't see where i am overwriting
the
previous field values.
Show us the full error text do not just summarize.
i would like to have something like, {1:
oops i forgot to count lines,
MainDictionary = {}
N = 0
M = 0
for line in open('data_file', 'r'):
if line:
if M < 3:
N += 1
M += 1
a, b = line.split(" = ") # "=" is in between spaces whish gives
you only two variables.
if a == 'Field':
maybe this can help
MainDictionary = {}
N = 0
for line in open('data_file', 'r'):
if line:
N += 1
a, b = line.split(" = ") # "=" is in between spaces whish gives you
only two variables.
if a == 'Field':
MainDictionary[N] == {}
elif a == 'Index':
i am filling a dictionary with a dictionary and my values for
isegment[field] are identical. i can't see where i am overwriting the
previous field values.
my data looks like
Field = aa1
Index = 0.0
Value = 0.0
...
...
Field = aa2
Index = 0.01
Value = 0.5
...
i would like to have something lik