I have a csv file with 4 columns that I want to use to create menus.
For example, the second column has values such as "TEST", "QA", "PROD" and a couple of others. I want to take all the values from the second column, weed out the duplicates, then create a menu allowing the users to select all the records with, say, QA in the second column. How is the best way to go about this? (Later I want the user to be able to pick values from more than one column to pick selected records with)
Please keep in mind that I am very new to Python. I can do this in BASH with select/case construct but can not find how to do it in Python.
Thanks,
John
ennoil
0
Newbie Poster
Recommended Answers
Jump to PostHere is one approach.
Assuming the data file is not very big, you can read the whole thing into memory and manipulate it from there. Otherwise, you may want to read just the second column from the csv file to produce the menu.import csv data = …
Jump to PostYes, that should be possible. That requires a little change in the code I posted previously. Namely, a change to the menu variable. It used to be a
set
, which is unordered. Now, we want to make it into a list and make use of the fact that …
All 6 Replies
sergb
7
Junior Poster
ennoil
0
Newbie Poster
woooee
814
Nearly a Posting Maven
sergb
7
Junior Poster
ennoil
0
Newbie Poster
sergb
7
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.