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


This question should be posted in StackOverflow.

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

import pandas as pd


for each in names:
    print(df.loc[df['Name'] == each, 'ID'].iloc[0])
  • 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 '18 at 5:25

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