I tried the following code, okay firstly I studied file operation today itself, with it a lot of dict & strings doubts get solved. What I tried was counting the total no. of individual words, store them string by string in a dictionary dicword, (after import codec 1st),

But the output was something like this for the file "Singapore.txt". NOTE: The input file had quite a few words so I have copied & pasted the whole error part. The file is attached so you can try for yourself & tell me what the goodie am I doing wrong.

Q1: this is not the way I think dicword should have printed.isn't it supposed to print like key:value??Q2: the code runs in 1st attempt! but then some error crops up. So why did the code run like following at all, & why does it not show in the dictionary formatQ3: Can anyone explain what do the arrowed errors mean in simpler terms?

Firstly, as u are not trained in Singapore, any family physician or specialist will be conditionally registered only.You will be "supervised" when working in a hospital. Full fledged specialist in their country cannot practice as consultant ( or attendings ). You will start off as a registrar ( or resident) Unfortunately, you cannot immediately setup a private practice.

For family physicians ( General practitioners, or GP as we call them that here), the typical supervision period is about 4 years before an endorsement from ur supervisor earns u the full registeration. For specialist it's usually 2 years. Google for SMC singapore registerable qualifications to see the list of specialist certs recognised / or basic MBBS/MD for general practitioners.

You can also google for Singapore General hospital, tan tock Seng hospital, Changi Hospital to look up the careers section to find people to contact. Generally, it's easier to come here to work if you contact them

There is no shortage of private GP clinic all around. In any neighborhood, the ratio of GPs to a grocery stores is about 1:1. A survey done in 2006 shows the average net income for a private GP to be about 120K/pa ( sing $$ ). The only issue is that a prior survey done in 1996 show an annual salary of about $120K/pa too. That means that accounting for inflation, GP salary actually drop over the 10 year period.

Senior GP in government hospital gets abotu 8K/per mth ( but they received a form of compulsory savings contribution and bonus + leave etc, so it sorta evens out with private sector). Of course, the private GP can offer other things, amongst which are aesthetic medicine. Some business savvy GPs also set up practise in young estates focusing on child health. "Examplary" cases of private GPs who evaded $11 million in tax over 5 years was all over the newspapers years ago.However the workload is quite different. Gov GPs are overloaded, a few years ago, they reported seeing up to 100 patients a day compared to about 30-40 for private GP. Nowadays, with more graduates and overseas docs, it drop to about 50 patients a day. We are also utilising APN( advance practising nurses, similar to Physician assistants in the US ) that can carry out simpler duties of a GP, ( like take BP, etc). It looks to improve as gov is increasinglyaware of the need to have a strong primary care force as the population gets older.

Ok. so with a 10K/per mth pay, what the standard of living like? Cars are expensive, but EVERYONE in this thread fail to mention that public transport here is good( trains, bus, taxis) It's a small place and quite efficient, so you do not really need a car. If you do need a car, a jap made will cost you about 1.2K/mth, which is not too bad at 10%. Food ranges from $2.5 ( YES, $2.5) for the fill up your stomach type to $20 for a simple course at a eatery.---------------------------------------------------------------------------UnicodeDecodeError Traceback (most recent call last)<ipython-input-82-1a71c5571578> in <module>() 1 dictxt={} 2 count=0----> 3 for line in f: ## iterates over the lines of the file 4 dictxt[count]=line, 5 print line,

C:\WinPython-64bit-2.7.3.3\python-2.7.3.amd64\lib\codecs.pyc in next(self) 613 614 """ Return the next decoded line from the input stream."""--> 615 line = self.readline() 616 if line: 617 return line

C:\WinPython-64bit-2.7.3.3\python-2.7.3.amd64\lib\codecs.pyc in readline(self, size, keepends) 528 # If size is given, we call read() only once 529 while True:--> 530 data = self.read(readsize, firstline=True) 531 if data: 532 # If we're at a "\r" read one extra character (which might

{1: 3, 'Firstly, as u are not trained in Singapore, any family physician or specialist will be conditionally registered only.You will be "supervised" when working in a hospital. Full fledged specialist in their country cannot practice as consultant ( or attendings ). You will start off as a registrar ( or resident) Unfortunately, you cannot immediately setup a private practice.\n': 1}

it's like first key =>1second key is not key but a whole string of sentences to which the value is 1...

stranac wrote:It looks like utf-8 is not the correct encoding for that file.The reason it works for a few lines is it only encounters a character it can't decode as utf-8 later in the file.

It's not the dict that is printed, it's individual lines that you print with

logic is:wird=0 for key, value in dictionary items for strings in values/key if word != strings then for strings in dicword.values(): start a counter (if there were those strings found earlier in dicword count=counter value if not found count = counter+1 #counter=0 initially & reset to 0 at the end of this for loop) which is count=newcount+1 under the same indentation below for loop means its not under for loop so: condition was if word!=strings, in any case word=strings dicword[key which is word]=count reset count reset newcount counter

else: if word ==strings another count increment count=pointing to this tempelif value finally dicword[key which is word]=count reset count

The point if if the same word was found it would increment if not found which will be the usual case in a sentence,search for it in the dictionary,add the counts from this counter and replace else just add this new word to dict with count=1Repeat.

stranac wrote:Ok, that doesn't look like a utf8 encoded file at all.You shouldn't use codecs.open() to open it, you can just use he built-in open() function.

lovecodecakes wrote:Q: What would be happening when print dicword is being given out at the last?

You just need to fix your code and see for yourself.But if I understood your first code correctly, it would pretty much look like you expected.

lovecodecakes wrote:And how would you suggest to uncomplicate it?

That depends on what the code is actually meant to do, but a few things are:

You don't need a dict for storing the file's lines. You can use a list, or just do stuff with lines as you loop the file

You have a count variable in the for loop, but you reset it to 0 without using it

The variables you're creating might not all be needed, but it's hard to tell since I don't know why you're creating them

I can't say much about the rest of the code, since I don't know what you're actually trying to do.If you explain that, maybe I can give you some more suggestions.

The whole thing is based off f.read().split(), which splits the entire string of the text file into a list of words indexed by the space in the file. At that point if your want, you can strip off puncuation, etc.

The try/except is there because if you rearrange their statments, it will reassign whatevger value it "was" at to 1, losing the data, instead it first tries to add 1 to the value of that key, if the key doesnt exist, it gets a keyerror, at that point moves to the except and creates that key with value of one, so the next time around if it comes across that word, it increments it, and bypasses the except

The whole thing is based off f.read().split(), which splits the entire string of the text file into a list of words indexed by the space in the file. At that point if your want, you can strip off puncuation, etc.

The try/except is there because if you rearrange their statments, it will reassign whatevger value it "was" at to 1, losing the data, instead it first tries to add 1 to the value of that key, if the key doesnt exist, it gets a keyerror, at that point moves to the except and creates that key with value of one, so the next time around if it comes across that word, it increments it, and bypasses the except

The whole thing is based off f.read().split(), which splits the entire string of the text file into a list of words indexed by the space in the file. At that point if your want, you can strip off puncuation, etc.

The try/except is there because if you rearrange their statments, it will reassign whatevger value it "was" at to 1, losing the data, instead it first tries to add 1 to the value of that key, if the key doesnt exist, it gets a keyerror, at that point moves to the except and creates that key with value of one, so the next time around if it comes across that word, it increments it, and bypasses the except

words is the dict, word is the key, which is each word in string (which will include the punctuation, etc.), and the value is an integer, which of course can increment, which is the count of each key (word) in the file

@metal Your python tutorial are like short notes, are awesome!So here, as you quoted the codeI tried something on that line, but a little different. I also shortened the file a lot for everyone to try out different sorting ways.This is what I tried.

The whole thing is based off f.read().split(), which splits the entire string of the text file into a list of words indexed by the space in the file. At that point if your want, you can strip off puncuation, etc.

The try/except is there because if you rearrange their statments, it will reassign whatevger value it "was" at to 1, losing the data, instead it first tries to add 1 to the value of that key, if the key doesnt exist, it gets a keyerror, at that point moves to the except and creates that key with value of one, so the next time around if it comes across that word, it increments it, and bypasses the except

@yoriz, this is a great forum for learning python. I am a newbie at this & im definitely gona try this out & learn new sorting methods. Remembering strings & print format specifications & their numerous functions is a lil wee bit tough at the start. still practicing.

metulburr wrote:there are other ways to do the same without the try/except way too.

you created a words dictionary & dictionaries can increment??

words is the dict, word is the key, which is each word in string (which will include the punctuation, etc.), and the value is an integer, which of course can increment, which is the count of each key (word) in the file