I have two separate CSV files that I need to have imported and read based on user input. We'll call the two files test1.csv and test2.csv. The user will be prompted to input if they want test1 or test2.
After inputting which CSV file they want, the user will be prompted a few other questions to select which rows of data they need. My CSV file data looks like this:
Column A, Column B, Column C, Column D`
Row 1, 1, 2, 3
Row 2, 4, 5, 6
If the user inputs Row 2, I'd like to return Columns B, C, and D as the result.
I'm new to python and unsure the coding to print the correct rows based off user input. I'm also unsure how to pick which CSV file gets pulled based on input.
As a work around, I wrote all the CSV data out in if/else statements within the code, but would prefer to keep the data in CSV format.
'vehicle = input('Enter CSV File:')
if vehicle == 'Test2':
print ("Row Titles")
print ("1.Row 1")
print ("2.Row 2")
choice = input('Row #:')
Column B= '1'if choice == '1' else '2' if choice == '2' else
0' Column C= '2' if choice == '1' else '5' if choice == '2' else '0' Column D= '3' if choice == '1' else '6' if choice == '2' else '0'
print (column b+ column c+ column D)
elif vehicle == "Test2":
repeat code above with options for CSV Test2 file
else: print ('invalid input')'