-1

I have a dataset and some data. When user selects particular data, the relevant rows/columns of it should be displayed. I have a csv file with different professions, their average pay, locations and skills needed. Now if the user selects a profession, everything linked to this profession tuple should be displayed.

Example: the columns of row are : Lawyer, $45000, US and Canada, Degree in law.

Now if user selects his profession to be lawyer, various options like $45000, US and Canada should be displayed one after the other. How Can I do this directly from a CSV file?

I will design this part of website in python flask

san guine
  • 49
  • 2
  • 5

1 Answers1

0

To answer your question of whether you can do this directly from a csv file, well, I dont think there is a way to validate information or search records directly from a CSV. You could, however, try one of the following approaches. One way this can be done is by,simply opening the csv file and saving each line/record as a sublist and then appending it to a parent list. Add the following code snippet to your application:

final_list=[]
with open('your_file.csv', 'r') as f:
  result = [line.strip(',') for line in f] 
  final_list.append(result)
print(final_list)
#[[Lawyer, $45000, US and Canada, Degree in law],
#[Doctor...],]

In case you want to use a python module then check this :Someone has already answered a similar question.

Hope this helps :)