hipom_data_mapping/data_preprocess/check_data/check.py

70 lines
1.2 KiB
Python
Raw Normal View History

# %%
import pandas as pd
import re
import os
# Get the current working directory
current_path = os.getcwd()
print(current_path)
# %%
file_path = '../../data_import/exports/raw_data.csv' # Adjust this path to your actual file location
old_df = pd.read_csv(file_path)
new_df = pd.read_csv('../exports/preprocessed_data.csv')
# %%
# compare changed rows
cond = old_df['tag_description'] != new_df['tag_description']
val1 = old_df[cond]['tag_description']
val2 = new_df[cond]['tag_description']
df = pd.DataFrame({
'column1': val1,
'column2': val2
})
df.to_csv('desc.csv')
# %%
# compare changed rows
cond = old_df['unit'] != new_df['unit']
val1 = old_df[cond]['unit']
val2 = new_df[cond]['unit']
df = pd.DataFrame({
'column1': val1,
'column2': val2
})
df.to_csv('unit.csv')
# %%
set(val2)
# %%
desc_set = list(set(df[df['MDM']]['tag_description']))
with open('output.txt', 'w') as file:
print(desc_set, file=file)
# %%
test = 'M/E(S) something'
print(re.sub(r'\bM/E(.)', r'MAINE ENGINE \1', test))
# %%
test = 'NO.345A ENGINE'
print(re.sub(r'\bNO\.(?=\d)\b', r'NO', test))
# %%
test = 'S/G VLOT.'
print(re.sub(r'VLOT\.', 'VOLT', test))
# %%
description = 'NO3 GENERATOR WINDING TEMPERATURE(T)'
re.sub(r'\s+', ' ', description)