Hello,
the idea of the following program is to parse a frequency list of the
form FREQUENCY|WORD, to store the frequency of a word in a dictionary
(and to do some things with this information later).
I have done this many many times. Suddenly, it does not work any more:
The value frq[key] is
Simon Strobl wrote:
the idea of the following program is to parse a frequency list of the
form FREQUENCY|WORD, to store the frequency of a word in a dictionary
(and to do some things with this information later).
I have done this many many times. Suddenly, it does not work any more:
The
On Apr 23, 1:16 pm, Simon Strobl [EMAIL PROTECTED] wrote:
Hello,
the idea of the following program is to parse a frequency list of the
form FREQUENCY|WORD, to store the frequency of a word in a dictionary
(and to do some things with this information later).
I have done this many many times.
On Apr 23, 12:16 pm, Simon Strobl [EMAIL PROTECTED] wrote:
Hello,
the idea of the following program is to parse a frequency list of the
form FREQUENCY|WORD, to store the frequency of a word in a dictionary
(and to do some things with this information later).
I have done this many many
Simon Strobl wrote:
Hello,
the idea of the following program is to parse a frequency list of the
form FREQUENCY|WORD, to store the frequency of a word in a dictionary
(and to do some things with this information later).
I have done this many many times. Suddenly, it does not work any more:
The
kdwyer a écrit :
On Apr 23, 12:16 pm, Simon Strobl [EMAIL PROTECTED] wrote:
(snip)
#!/usr/bin/python
import sys
frqlist = open('my_frqlist.txt', 'r')
(snip)
frq = {}
for line in frqlist:
line = line.rstrip()
frequency, word = line.split('|')
frq[word] = int(frequency)
(snip)
On Apr 23, 1:22 pm, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
kdwyer a écrit : On Apr 23, 12:16 pm, Simon Strobl [EMAIL PROTECTED] wrote:
(snip)
#!/usr/bin/python
import sys
frqlist = open('my_frqlist.txt', 'r')
(snip)
frq = {}
for line in frqlist:
line =
flippancyYou musts have missed the memo. The rules of the universe
changed at 0834 UST yesterday, and all functioning Python programs
stopped working./flippancy
As always, the rules of the universe have not changed. (Or, at least,
I do hope so.)
It seems that the cause of my problem was my
Simon Strobl [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| Any hints?
For future reference, I would consider using sample data in the file itself
for debugging -- to separate an algorithm problem from a file problem:
|
|
|
Glauco Silva [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I would like to know if the dictionary can sort with a function that i
give to then!
No. You have to either make a list of key,value items and sort that,
possibly with a cmp or key parameter
items = d.items()
I´m with problem inDictionaries !
I would like to know if the dictionary can sort with a function that i give to then!
Because i need to have a dictionary sort by key !
For exemple :
dict = {}
dict[50] = "fifty"
dict[129] = "a hundred twenty nine"
print dict
{129: "a hundred twenty nine", 50:
11 matches
Mail list logo