Question: I need to read a CSV file from a folder, which is generating from another Module. If that Module fails it won't generate the folder which will have a CSV file.
Example:

```
path = 'c/files' --- fixed path

```

When Module successfully runs it will create a folder called output and a file in it.

```
path = 
'c/files/output/somename.csv'

```

But here is a catch everytime it generates a output folder, CSV file has a different name.
First i need to check if that output folder and a CSV file is there or not.
After that I need to read that CSV.

Answer: 
The following will check for existance of output folder as well as csv file and read the csv file:

```
import os
import pandas as pd
if 'output' in os.listdir('c/files'):
    if len(os.listdir('c/files/output')>0:
        x=[i for i in os.listdir('c/files/output') if i[-3:]=='csv][0]
        new_file=pd.read_csv(x)

```
[`glob.glob`](https://docs.python.org/3/library/glob.html#glob.glob) can help.

`glob.glob('c/files/output/*.csv')` returns either an empty list or a list with (hopefully) the path to a single file