1
0
Fork
You've already forked Cheese_Cleaner
0
Cleaning script for some cheese data
  • Python 100%
Find a file
2024年11月26日 20:48:43 -05:00
data Initial commit 2024年10月01日 20:55:27 -04:00
.gitignore Initial commit 2024年10月01日 20:55:27 -04:00
Cheese_cleaner.py Clean up some spelling 2024年11月26日 20:48:43 -05:00
LICENSE Initial commit 2024年10月01日 20:55:27 -04:00
README.md Initial commit 2024年10月01日 20:55:27 -04:00

Cheese Cleaner

This is a Python script to take some Canadian cheese data from the government, clean the data, and write out a new CSV.

Please see the individual functions in the Cheese_Cleaner class to see what is being cleaned.

Usage

usage: Cheese_Cleaner.py [-h] [--input INPUT] [--output OUTPUT]
Clean the cheese data.
options:
 -h, --help show this help message and exit
 --input INPUT Input file path (default: data/cheese_data.csv)
 --output OUTPUT Output file path (default: cheese_clean.csv)

Adding Cleaning Of Other Fields

To add cleaning for a new field, declare a new function for it in the Cheese_Cleaner class.

For example, to add a cleaner for a column called "Foo", I would create a function in Cheese_Cleaner called process_Foo that looks like this:

def process_Foo(self, fields: List[str]) -> List[str]:
 """capitalize occurrences of 'bar'"""
 for index, field in enumerate(fields):
 if field == "bar":
 fields[index] = field.capitalize()
 return fields

This takes a list of fields - the data in the column - and returns a modified list. The list should be the same length (number of rows in the data). The data can be modified in place and returned like I do in the example.

Adding A General Normalization

There is a function in Cheese_Cleaner called normalize(). This function is called on every field in the data. (Be careful with this one!)

License

This project is licensed under the MIT license - see the LICENSE file for details.

Individual source files may contain the following tag instead of the full license text:

SPDX-License-Identifier: MIT

Using SPDX enables machine processing of license information based on the SPDX License Identifiers and makes it easier for developers to see at a glance which license they are dealing with.