Hi there can someone help
i am trying to search for a file name in a csv (in Column A) then when it finds it print just the 2nd column (Colum B) not the whole row, this prints both the coloumns in the csv
-------------------
import os
f_name = os.listdir(r'C:\Users\Peter\Documents\Python test\Files')[0]
print(f_name)
import csv
data=[]
with open ("test.csv") as csvfile:
reader = csv.reader(csvfile)
for row in reader:
data.append(row)
col = [x[0] for x in data]
if f_name in col:
for x in range(0,len(data)):
if f_name ==data[x][0]:
action = print(data[x])
else:
print("File not listed")
i am trying to search for a file name in a csv (in Column A) then when it finds it print just the 2nd column (Colum B) not the whole row, this prints both the coloumns in the csv
-------------------
import os
f_name = os.listdir(r'C:\Users\Peter\Documents\Python test\Files')[0]
print(f_name)
import csv
data=[]
with open ("test.csv") as csvfile:
reader = csv.reader(csvfile)
for row in reader:
data.append(row)
col = [x[0] for x in data]
if f_name in col:
for x in range(0,len(data)):
if f_name ==data[x][0]:
action = print(data[x])
else:
print("File not listed")