Retreving results after a keyword



I am trying to do a small analysis using Jupyter note book and I would like to retrieve the count and also other column information after the key word Manufacturing? Is this possible if yes how do I do it ?
This is the code that I have used

%matplotlib inline
import matplotlib as plt
import pandas as pd
data = pd.read_csv(“WTdoc.csv”,encoding = “ISO-8859-1”)

One of the columns in the csv is the folder path, I would like to retrieve results based on a key word in this folder path

The CSV files contain the below information

Document Name | Document Number | Folder| Folder Path
One of the values in folder path is /Default/AD/Manufacturing/Techincal ( There are of course many other paths like these )
I am interested in filtering my results based on the path /Default/AD/Manufacturing* and also to retrieve the count of files that are residing in this folder path, How to achieve this in Python?


The code below will list out all the files in the given path.

import os

You can use regular expressions or regex to filter your content based on a keyword.



Hi Joshi,
Thanks for your reply,

Import OS will help me to retrieve results which are on my local computer, I would like to retrieve results which are present in the csv file


Hi Joshi,
this is the error message that I get when I use import OS functionality

FileNotFoundError Traceback (most recent call last)
in ()
1 import os
----> 2 os.listdir("/Default/AD/Manufacturing")

FileNotFoundError: [WinError 3] The system cannot find the path specified: ‘/Default/AD/Manufacturing’


@Athmanand as per the error the path is incorrect.


AD_doc.csv (16.8 KB)
Hi Joshi,
Thanks a lot for your quick reply,

The path exists in the csv file, Please find the attachment which will give you an idea
As far as I am aware if I use import OS it will find for files on my local drive which of course I don’t have in this case
Please correct if my understanding is wrong


Please check whether all the paths in your CSV file are actually there in your system.


Hi Joshi,
It’s not in my system, this extract is from a different data lake altogether and I would like to filter my results based on values inside the CSV file, Just like we apply a keyword in Excel and it gives us results based on the keyword


I figured out a way to solve this issue finally
data[data[“Folder Path”].map(lambda x: x.startswith"Folder Path)
This will act as very much similar to filter function in excel