Python - Finding keywords in a CSV
Question: Okay, so basically, I have this project to create a troubleshooting program
for an electronic device. It asks which device you have, so for example phone,
then asks for the make, model, etcetera..

I then want the program to ask, 'What is the problem', which is fine, but I
want to have a CSV file with problems in one column, and solutions in the next
column.

So from the users input of for example saying 'My phone will not charge' I
want it to search the CSV file for, for example 'charge', or 'not charge', and
then print out the solution.

How would I go about doing this? I've been sat here thinking for a while now,
but I have no clue.

If you guys have any other suggestions of doing this, please offer away.


Answer: So you have keywords, problems and solutions.

Usually, one problem can, and will have multiple solutions.

So basically, if you are using a csv, that means that you'll have a column
'solution' with a few times the same solution. Which isn't very good in terms
of maintenance (let's say you've made a typo error in the solution, how do you
change it everywhere?)

It's really easy to import a csv to a relational database (for instance MySQL
and using MySQL Workbench). Using SQL allows you to use great functions, is
way faster than using csv, and overall allows you later to use an ORM to make
something great like plugging django on your database.

    
    
    Tables : 
        - word : id_word, word
        - problem : id_problem, problem
        - solution : id_solution, solution
        - problem_solution : id_problem, id_solution (a problem can have multiple solutions).
        - word_problem : id_word, id_problem (a word can be found in multiple problems).
    
    Logic :
        ask user for problem.
        split problem on space (" ") to get words.
        for every word, ask your db for related problems.
        show your user distinct related problems (ordering by the most occuring problem)
        user selects a problem
        fetch solutions for the problem and show them.
    

