Giter Site home page Giter Site logo

juanc004 / cp2f-csv-transformer Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 9 KB

This Python script is designed to transform raw CSV data from CP2F evaluations into a more readable and standardized format. The script reads the input CSV, filters and renames fields, reorders columns, and then saves the transformed data into a new CSV file.

License: MIT License

Python 100.00%

cp2f-csv-transformer's Introduction

CP2F-CSV-Transformer

Description

This Python script is designed to transform raw CSV data from CP2F evaluations into a more readable and standardized format. The script reads the input CSV, filters and renames fields, reorders columns, and then saves the transformed data into a new CSV file.

Requirements

  • Python 3.x
  • Pandas library

You can install the required package using:

pip install pandas

How to Run

  1. Update the csv_path in the script with the path to your input CSV file.
  2. Update the output_csv_path with the directory where you'd like to save the transformed CSV file.
  3. Run the script.

Features

  • Reads raw CP2F data from a CSV file.
  • Filters the DataFrame to only include specified fields.
  • Renames columns to standardized names.
  • Reorders columns to match a specific format.
  • Saves the transformed DataFrame to a new CSV file.

Code Walkthrough

Import Required Libraries

import pandas as pd

Read CSV File into DataFrame

csv_path = ''  # Replace with your CSV file path
cp2f_df = pd.read_csv(csv_path)

Display Column Names

print("Columns in the DataFrame:", cp2f_df.columns)

Filter DataFrame

required_fields = [
    'Date', 'About', 'Candidate', 'Iteration', 'Top 3 or Bottom 3', 'Trainability',
    'Stress Tolerance', 'Drive', 'Communication',
    'Problem Solving', 'Teamwork', 'Physical Fitness', 'Comment'
]
filtered_cp2f_df = cp2f_df[required_fields]

Rename Columns

transformed_fields = {
    'About': 'Reviewer',
    'Candidate': 'Reviewee',
    'Iteration': 'Iteration',
    'Top 3 or Bottom 3': 'T3B3',
    'Comment': 'Comment',
    'Trainability': 'Trainability',
    'Stress Tolerance': 'Stress Tolerance',
    'Drive': 'Drive',
    'Communication': 'Communication',
    'Problem Solving': 'Problem Solving',
    'Teamwork': 'Teamwork',
    'Physical Fitness': 'Physical Fitness'
}
gpsddb_df = filtered_cp2f_df.rename(columns=transformed_fields)

Reorder Columns

gpsddb_columns_order = [
    'Reviewee', 'Date', 'Iteration', 'Trainability', 'Drive', 'Stress Tolerance',
    'Communication', 'Problem Solving', 'Teamwork', 'Physical Fitness', 'T3B3', 'Comment', 'Reviewer',
]
gpsddb_df = gpsddb_df[gpsddb_columns_order]

Save Transformed DataFrame

output_csv_path = '/summarized_PF_1.csv'  # Replace with your desired output path
gpsddb_df.to_csv(output_csv_path, index=False)

Confirmation Message

print(f"Transformed DataFrame has been saved to {output_csv_path}")

License

This project is licensed under the MIT License. See the LICENSE.md file for details.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.

Changelog

For all notable changes to this project, see CHANGELOG.md.

cp2f-csv-transformer's People

Contributors

juanc004 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.