python
Computing N Grams using Python
I needed to compute the Unigrams, BiGrams and Trigrams for a text file containing text like:
Python pretty XML printer with lxml
After reading from an existing file with ‘ugly’ XML and doing some modifications, pretty printing doesn’t work. I’ve tried etree.write(FILE_NAME, pretty_print=True).
Extract files from zip file and retain mod date?
I’m trying to extract files from a zip file using Python 2.7.1 (on Windows, fyi) and each of my attempts shows extracted files with Modified Date = time of extraction (which is incorrect).
How to create in-memory file object
I want to make a in-memory file to use in pygame mixer. I mean something like http://www.pygame.org/docs/ref/music.html#pygame.mixer.music.load which says load() method supports file object.
How to Ignore Duplicate Key Errors Safely Using insert_many
I need to ignore duplicate inserts when using insert_many with pymongo, where the duplicates are based on the index. I’ve seen this question asked on stackoverflow, but I haven’t seen a useful answer.
Plot bar graph from Pandas DataFrame
Assuming i have a DataFrame that looks like this:
Python code to read registry
from _winreg import * """print r"*** Reading from SOFTWAREMicrosoftWindowsCurrentVersionRun ***" """ aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE) aKey = OpenKey(aReg, r"SOFTWAREMicrosoftWindowsCurrentVersionUninstall") for i in range(1024): try: asubkey=EnumKey(aKey,i) val=QueryValueEx(asubkey, "DisplayName") print val except EnvironmentError: break Could anyone please correct the error…i just want to display the “DisplayName” within the subkeys of the key the HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall This is the error … Read more
Finding the user’s “My Documents” path
I have this small program and it needs to create a small .txt file in their ‘My Documents’ Folder. Here’s the code I have for that: