TG tools update
This commit is contained in:
@@ -6,10 +6,16 @@ import shutil
|
||||
import pandas as pd
|
||||
import logging
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from src.My_Logger.project_logger import LoggerClass
|
||||
from src.PostgresSQL.databaseHandler import DatabaseHandler
|
||||
from src.utils.utils import load_config, size_of_file
|
||||
|
||||
project_path = Path(__file__).parent.parent.parent.absolute()
|
||||
data_path = os.path.join(project_path, 'data')
|
||||
config_path = os.path.join(project_path, 'config')
|
||||
|
||||
|
||||
def process_message_text(text):
|
||||
if isinstance(text, str):
|
||||
@@ -157,20 +163,8 @@ class MessageUploader:
|
||||
return file_path.replace(file_name, new_file_name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
config = load_config('../config')
|
||||
config['database'] = "TestDB"
|
||||
tg = MessageUploader(config_path='../config',
|
||||
local_logger=LoggerClass().get_log(logging.DEBUG),
|
||||
local_load_path='E:\\SNSFiles\\ChatExport_2023-12-27',
|
||||
local_file_db_path=config['file_db_path'],
|
||||
size_limit=0.25)
|
||||
|
||||
|
||||
# with open('../data/Rynco_Group.txt', 'r', encoding='utf-8') as f:
|
||||
# file_content = f.readlines()
|
||||
def upload_didi_saved_message_to_db():
|
||||
msg_list = []
|
||||
|
||||
csv_content = pd.read_csv('../data/Rynco_Group.csv', encoding='utf-8')
|
||||
for row, content in csv_content.iterrows():
|
||||
try:
|
||||
@@ -194,6 +188,17 @@ if __name__ == "__main__":
|
||||
}
|
||||
msg_list.append(target)
|
||||
tg.upload_to_database(msg_list, 'Rynco_Group_private_supergroup')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
config = load_config(config_path)
|
||||
config['database'] = "TestDB"
|
||||
tg = MessageUploader(config_path=config_path,
|
||||
local_logger=LoggerClass().get_log(logging.DEBUG),
|
||||
local_load_path='E:\\SNSFiles\\ChatExport_2023-12-27',
|
||||
local_file_db_path=config['file_db_path'],
|
||||
size_limit=0.25)
|
||||
tg.do_upload()
|
||||
tg.db_handler.close()
|
||||
print('done')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user