[Tutor] help!

Alan Gauld alan.gauld at btinternet.com
Tue Jan 26 15:08:19 EST 2016


On 26/01/16 18:05, Chelsea G wrote:

> creating a keyword search. For example, if I want to search for the word
> Tool in the value and see what keys are associated with that. So say the
> value I have to search is Tool World and I want to know what key is
> associated with Tool World I search Tool World and it comes up with several
> results like missing or not updating and catalog issue. 


> I have the basic code for it figured out

Not if its the code you attached you haven't.
It won't do anything because all of the code is inside
the class definition.  So until you create an instance
of the class nothing will happen.

And that's assuming there are no other errors, and I'm
pretty sure I can see at least 1 more.

> ... I want my code to search the csv
> file that I am importing and then take the info I am getting from the
> search results and put it in its own text file. Also, I dont want to have
> to create the mydict line with the keywords I want to be able to type in a
> value like Tool and search through the csv file and then output the results
> to a text file. I have attached my code.

That's all fine and dandy but do it one piece at a time,
don't try to make a huge program work all at once.
Pick one thing and get it working.
I suggest:
1) load the csv file into a dict and print out the result.
2) implement user entry of a dict item, print the result
3) implement the search, print the found items value(s)
4) output the results to a text file (BTW why have you
   JSON functions if you want a text file? Or do you
   really mean a JSON file?

Bite it off one bit at a time. It's much easier to modify
working code than to fix everything at once.

BTW you were lucky your attachment made it through.
The list server often loses them. Its not a lot of code
so just paste it into your mail messages. Its much easier
for us to see and respond to that way.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list