27 Solved Topics

Remove Filter
Member Avatar for
Member Avatar for gishi

hi! i want to place the contents of a dictionary into a csv file. Can someone help me with this? i already have the code in reading the csv file [CODE] import csv reader = csv.reader(open("c:\sample.dat")) for row in reader: print row [/CODE] i want the first element of the …

Member Avatar for Gribouillis
0
15K
Member Avatar for Saran_1

Here is the CSV file that I am working with: `"A","B","C","D","E","F","G","H","I","J" "88",18,1,"<Req TID=""34"" ReqType=""MS""><IISO /><CID>2</CID><MemID>0000</MemID><MemPass /><RequestData><S>[REMOVED]</S><Na /><La /><Card>[REMOVED]</Card><Address /><HPhone /><Mail /></ReqData></Req>","<Response T=""3"" RequestType=""MS""><MS><Memb><PrivateMembers /><Ob>0-12-af</Ob><Locator /></Memb><S>[REMOVED]</S><CNum>[REMOVED]</CNum><FName /><LaName /><Address /><HPhone /><Email /><IISO /><MemID /><MemPass /><T /><CID /><T /></MS></Response>",0-JAN-10 12.00.02 AM,27-JUN-15 12.00.00 AM,"26",667,0 "22",22,1,"<Req TID=""45"" ReqType=""MS""><IISO /><CID>4</CID><MemID>0000</MemID><MemPass /><RequestData><S>[REMOVED]</S><Na /><La /><Card>[REMOVED]</Card><Address /><HPhone /><Mail /></ReqData></Req>","<Response …

0
185
Member Avatar for ogsirus

Hi guys, I am trying to write a program which picks the closest number possible out of a dictionary. The dictionary contains 50 doubles values, and I use a random double to pick the number i want to get the closest to if that makes sense. Currently I am using …

Member Avatar for ogsirus
0
853
Member Avatar for psvmr

I have been trying to create a program which the teacher log in to view the scores of a test of a school class. The scores are stored in a text file like this: Charlotte:7 Charlotte:4 Charlotte:3 Chelsea:2 Chelsea:9 Chelsea:5 Jeff:1 Jeff:10 As you can see there are multiple scores …

Member Avatar for vegaseat
0
670
Member Avatar for knan

I have a dictionary [CODE]dict1={'18':['4000','1234'],'12':['7000','4821','187','1860','123','9000']}[/CODE] I want to sort the keys and values such that, the output is, [CODE]dict1={'12':['123','187','1860','4821','7000','9000'],'18':['1234','4000']}[/CODE] I tried something! but it didn work [CODE]>>> for values in dict1: ... dict1[values].sort() ... >>> dict1 {'18': ['1234', '4000'], '12': ['123', '1860', '187', '4821', '7000', '9000']}[/CODE] Full sorting happens for …

Member Avatar for grantjenks
0
806
Member Avatar for flebber

What I am trying to do is delete the key value pairs out of a dictionary if the value is = 0. I seem not to be acheiving that so far. Python 2.7.5+ (default, Sep 19 2013, 13:48:49) [GCC 4.8.1] on linux2 Type "help", "copyright", "credits" or "license" for more …

Member Avatar for flebber
0
416
Member Avatar for nikki05

Hi, I would like to to to store the Name and Items of ComboBox into dictionary. With the below code,I am able to store them. However, Name of ComboBox is as counting ComboBox10 to ComboBox1n. I would like to store Name of ComboBox as ComboBox1,ComboBox2 rather than ComboBox10 to ComboBox1n …

Member Avatar for nikki05
0
551
Member Avatar for nikki05

Hi I am storing name and texts of controls (Label, Button, ComboBox, ListBox, etc.) into a dictionary. With ContainsKey, I am able to find the texts of Labels, Buttons, and RadioButtons. However, I am getting problem to find the items of ComboBox. Appreciate if you have an idea. If _dic.ContainsKey(selectedControl.Name) …

Member Avatar for nikki05
0
223
Member Avatar for Pallab.Bhk

Hey I have dictionary like following one dicts = {'met_293': ['81.0175','4','7','7','29.76','23','1','0','22','28.57','2','[KG]EHY'],'met_394': ['79.9579','4','7','7','29.76','18','3','0','15','28.57','2','EHY[ILV]'],'met_309': ['81.0175','4','7','7','29.76','23','1','0','22','28.57','2','[KG]EHY'],'met_387': ['79.9579','4','7','7','29.76','18','3','0','15','28.57','2','EHY[ILV]']} I want to remove keys which have same value like 'met_293' and 'met_309' those two keys have same value at 12th position which is '[KG]EHY' so i want my dictionary like this {'met_293': ['81.0175','4','7','7','29.76','23','1','0','22','28.57','2','[KG]EHY'],'met_394': ['79.9579','4','7','7','29.76','18','3','0','15','28.57','2','EHY[ILV]']} any …

Member Avatar for Pallab.Bhk
0
484
Member Avatar for TheWolverine

Hi all, I've browsed the net trying to find a paradigm to describe what I'm looking for but haven't been successful. So I'll try to explain it as succinctly as I can. Right now, for my PhD research, I've set out a few applications that take input files that have …

Member Avatar for TheWolverine
0
236
Member Avatar for heinlein_

Hi, I have a little problem. I want to replace words in a text, but only 'whole words'. That is, I'm looking for a method that changes "cat", but not "catfood". I know how to do it using re.sub, like this: re.sub(r'\bword\b', 'change', text) Only problem is, I'm using a …

Member Avatar for heinlein_
0
7K
Member Avatar for greatman05

Hello. What are some ways that one can work with (x,y) coordinate pairs in Python? I'm doing a homework assignment that requires me to create a program that can check for certain binary relations (reflexive, transitive, symmetric), and I'm having an issue coming up with the best approach for it. …

Member Avatar for greatman05
0
274
Member Avatar for Lucaci Andrew

I keep getting this error and i don't understand why. [code]Traceback (most recent call last): File "E:\University\Workspace eclipse\dictionares\src\dcts\dicts.py", line 105, in <module> fr_runt() File "E:\University\Workspace eclipse\dictionares\src\dcts\dicts.py", line 95, in fr_runt run.run() File "E:\University\Workspace eclipse\dictionares\src\dcts\dicts.py", line 58, in run self.data.write(file, key, value) File "E:\University\Workspace eclipse\dictionares\src\dcts\dicts.py", line 23, in write fh = …

Member Avatar for Lucaci Andrew
0
304
Member Avatar for Joe34

I'm trying to simply match these letters using php, but it's kind-of a complex matching formula... First, I have two arrays and one string. The arrays contain letters and the string is a near match of those letters. $a - [Array] Must be <= 7 $b - [Array] Must be …

Member Avatar for cereal
0
232
Member Avatar for pwolf

Stuck again, this time my problem is getting the dictionary to be sorted in ascending order. Please Advise! the following is what the task says: """ A sparse vector is a vector whose entries are almost all zero, like [1, 0, 0, 0, 0, 0, 0, 2, 0]. Storing all …

Member Avatar for pwolf
0
2K
Member Avatar for GeoBob

I want to create a function or a class method that will create a dictionary named by a variable that is passed in. By way of example, I'm creating a class method to read data from a table (in this case it's an ArcGIS table, but that's not critical) and …

Member Avatar for JoshuaBurleson
0
432
Member Avatar for JoshuaBurleson

So I've finally fixed up the functionality of an address book I've been writing (not on to utilizing a GUI yet of course though.)However to save or reclaim the data from the last use of the address book I, obviously, need to write and reclaim it from a .txt file, …

Member Avatar for JoshuaBurleson
0
239
Member Avatar for JoshuaBurleson

I am having issues finding a way to have the below program search for any given string of "query" in the keys of the dictionary AB and return the value, or the key and value. Thus far I just done what I have preset in the dictionary; Ashley and Joshua, …

Member Avatar for JoshuaBurleson
0
270
Member Avatar for Mark_48

The dictionary part isnt working. can anybody help?? [CODE] string path = @"C:\1\"; string[] file1_Lines = File.ReadAllLines(path + @"TraceSet.csv"); string file2 = File.ReadAllText(path + @"SBoxOutput.csv"); string[] file2_Lines = file2.Split(new string[]{"\r\n"}, StringSplitOptions.RemoveEmptyEntries); //creating 2 lists for average values of file1 and file2: List<float> averageFile1 = new List<float>(); List<float> averageFile2 = new …

Member Avatar for Mitja Bonca
0
155
Member Avatar for knan

Hi can anyone tell me how to remove empty keys in the following dictionary d={'a':[],'b':['1','2'],'c':[]} I want it to be d={'b':['1','2']} I tried this. But its showing error. I know its wrong to change the size of a dictionary during iteration. But is there any other way? [CODE]>>> for x …

Member Avatar for TrustyTony
0
18K
Member Avatar for knan

I have a list [CODE]x = ['abc','1','2','3','def','6','8','5','13','mcg','568','35469','6453'][/CODE] I want the output file in a dictionary as follows: [CODE]dict = {'abc':['1','2','3'],'def':['6','8','5','13'],'mcg':['568','35469','6453']}[/CODE] How can i do this?

Member Avatar for TrustyTony
0
203
Member Avatar for knan

I have dictionary with single element lists. [CODE]dictionary={'a':['A'], 'b':['B'], 'c':['C']} [/CODE] How can i change it to [CODE]{'a':'A', 'b':'B','c':'C'}[/CODE]

Member Avatar for TrustyTony
0
147
Member Avatar for techie1991

I want to sort a list of dictionaries using the inbuilt sort() function for lists. The problem is I am not able to understand, how to give the function a key.. Example: [CODE] a={'name':1,'data':200} b={'name':2,'data':400} c=[a,b] [/CODE] Now, I want to sort the list c with the key being a['name']. …

Member Avatar for TrustyTony
0
222
Member Avatar for jpob

Hey, i am new to python. I am making a translator in python 2.6 using basic commands. The translator is english to german. I need to use a i need to use a text file like this... at an brown braun cat raze etc. so far i have created lists …

Member Avatar for jpob
0
255
Member Avatar for doctorjo5

I know that this is an easy one but it is hard for me to figure out. I need to make a program that can: * Open the file and read through all of the lines in the file. (got this) * If a line starts with "Subject:", skip the …

Member Avatar for woooee
0
159
Member Avatar for furblender

Completely frustrating - I have been googling for a solution for this for a couple of hours now. I have this little bit of code that I wish to read a text file into a Python Dictionary. I used this dictionary format internally within the another piece of code I …

Member Avatar for furblender
0
3K
Member Avatar for chase32

I am trying to combine two multi-element dictionaries but am running into a problem. From the example below, what I expected was the dictionary x to contain all three unique combinations. What seems to have happened is that the y dictionary overwrote the x dictionary. Am I just using this …

Member Avatar for vegaseat
0
198

The End.