Data Analysis at a Startup
You're a data analyst at a thriving startup, and you're working on a project that requires advanced data filtration. The company stores data in CSV files. For this task, you've been given a CSV file that contains various pieces of information about the company's employees, including their names, ages, job roles, and countries. Your job is to write a Python program that reads the CSV file, filters the data based on the job role column, and prints the data for employees whose job role matches a specified input.
You should use the
csv
module in Python, which provides functionality to read and write CSV files. Your program should read the CSV file, filter the data based on the job role column, and print only the rows where the job role matches the given input.The first line of the input will be a string representing the name of the CSV file. The second line of the input will be a string representing the job role to filter by.
The output of your program should be the filtered data from the CSV file. Each line of output should represent a row from the file. The items in the row should be separated by commas. If there are no employees with the specified job role, the program should print
No employees found with the specified job role.
.Input | employees.csv | Output |
employees.csv
Data Analyst | Name,Age,Job Role,Country
John,28,Data Analyst,USA
Lucas,26,Data Analyst,UK
Mark,30,Engineer,USA
Peter,28,Manager,UK
Paul,26,Engineer,USA
Mary,30,Manager,UK
John,28,Manager,USA
Lucas,26,Manager,UK | Name, Age, Job Role, Country
John, 28, Data Analyst, USA
Lucas, 26, Data Analyst, UK |
Input | staff.csv | Output |
staff.csv
Sales | Job Role,Bonus
Finance,400
Consulting,600
Operations,500
Media,300 | No employees found with the specified job role. |
Note: The output format depends on the actual content of the CSV file. The headers should be in the first line of the output, followed by the data rows. Each line of output is a string where items are separated by a comma and a space. The employees in the output should be in the same order as they are in the input file.
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB