hipom_data_mapping/data_preprocess/check_data/check.py

59 lines
1018 B
Python

# %%
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 = 'kg/cm3'
print(re.sub(r'kg(?!\w|/)', 'flow', test))
# %%