├── CSV └── README.md /CSV: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | 3 | def filter_csv(input_file, output_file, column_name, filter_value): 4 | # Read the CSV file 5 | data = pd.read_csv(input_file) 6 | 7 | # Filter the data 8 | filtered_data = data[data[column_name] == filter_value] 9 | 10 | # Save the filtered data to a new CSV file 11 | filtered_data.to_csv(output_file, index=False) 12 | print(f"Filtered data saved to: {output_file}") 13 | 14 | if __name__ == "__main__": 15 | input_file = input("Enter the path to the input CSV file: ") 16 | output_file = input("Enter the path to the output CSV file: ") 17 | column_name = input("Enter the column name to filter by: ") 18 | filter_value = input("Enter the value to filter for: ") 19 | 20 | filter_csv(input_file, output_file, column_name, filter_value) 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CSV Data Processing 2 | 3 | This is a simple Python script to read a CSV file, filter the data by a specified criterion, and save the filtered data to a new CSV file. 4 | 5 | ## Requirements 6 | 7 | - Python 3.x 8 | - `pandas` library 9 | 10 | ## Installation 11 | 12 | 1. Clone this repository: 13 | ```bash 14 | git clone https://github.com/yourusername/csv_data_processing.git 15 | ``` 16 | 2. Navigate to the project directory: 17 | ```bash 18 | cd csv_data_processing 19 | ``` 20 | 3. Install the required libraries: 21 | ```bash 22 | pip install -r requirements.txt 23 | ``` 24 | 25 | ## Usage 26 | 27 | Run the script and follow the prompts: 28 | ```bash 29 | python filter_data.py 30 | --------------------------------------------------------------------------------