TypeError: argument of type 'WindowsPath' is not iterable - in open of pdf file with python
<p>Good day,</p>

<p>I want to open the pdf files that have a specific name from a directory . These file names are provided from a csv file input, which are in the second column.</p>

<p>I tried the follwing code, but I received an error message: </p>

<blockquote>
  <p>TypeError: argument of type 'WindowsPath' is not iterable</p>
</blockquote>

<p>How can I solve this problem and the pdf files to be opened
    according the input file?</p>

<p>And another issue: how can I fix if the
        input name is not an exact match with the pdf title,but I still want
        to open this file that contain the input name?</p>

<pre><code>import csv
import os
from pathlib import *

dir_path = Path('D:\\path\\pdf files')
pdf_files = dir_path.glob('*.pdf')

file1=open('INPUT.csv','r')
reader=csv.reader(file1,delimiter=';')
for pdf_file in pdf_files:
    for item in reader:
        file_name=item[1]
        print(file_name)#just to see the file name that I want to open 
        if file_name in pdf_file:
            os.startfile("%s"%(pdf_file))
file1.close()
</code></pre>

<p>Thank you in advance!</p>