0
$\begingroup$

The CSV file contains: ID,Name 1,AS 2,er 3,rtf 4,addfs

The list contains the name for example (er,rtf) I want to find the ID's corresponding to these names mentioned above How to find the ID's using the Python code.

Thanks in advance

$\endgroup$

1 Answer 1

0
$\begingroup$

This question should be posted in StackOverflow.

Store your CSV into a Pandas DataFrame and operate on that.

import pandas as pd

df=pd.read_csv('nameofyourcsv.csv')
names=('er','rtf')

for each in names:
    print(df.loc[df['Name'] == each, 'ID'].iloc[0])
$\endgroup$
1
  • 1
    $\begingroup$ @Sheetal Happy to help! If this answer (and any other answers to your questions in general) resolved your issue, please mark it as accepted by selecting the check mark below the voting buttons on the left. $\endgroup$
    – Anakimi
    Oct 11, 2018 at 5:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.