|
import os |
|
|
|
import pandas as pd |
|
|
|
ORIGINAL_FILE_PATH = os.path.realpath(os.path.join(os.path.dirname(__file__), "../originals/AmesHousing.txt")) |
|
PROCESSED_FILE_PATH = os.path.realpath(os.path.join(os.path.dirname(__file__), "../AmesHousing.csv")) |
|
|
|
def main(): |
|
print(f"Preprocessing [{ORIGINAL_FILE_PATH}]...") |
|
|
|
df = pd.read_csv(ORIGINAL_FILE_PATH, sep="\t") |
|
|
|
print(f"[{df.shape[0]}] rows loaded over [{df.shape[1]}] columns") |
|
|
|
|
|
df.columns = df.columns.str.lower().str.replace(" ", "_").str.replace("/", "_").str.replace(".", "") |
|
|
|
|
|
df = df.set_index("order") |
|
|
|
pd.DataFrame.to_csv(df, PROCESSED_FILE_PATH) |
|
print(f"Processed filed saved to [{PROCESSED_FILE_PATH}]...") |
|
|
|
|
|
if __name__ == "__main__": |
|
main() |
|
|