llm_knowledge_base / save_database_info.py
allinaigc's picture
Upload 35 files
b2e325f verified
raw
history blame
1.31 kB
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import re
from re import sub
import smtplib
import matplotlib.pyplot as plt
from itertools import product
from tqdm import tqdm_notebook, tqdm, trange
import time
import seaborn as sns
from matplotlib.pyplot import style
import warnings
from datetime import datetime
sns.set()
# style.use('seaborn')
import csv
def save_database_info(filepath, database_name, date):
# 读取CSV文件
# with open(f'./database_name.csv', 'r', encoding='utf-8') as file:
with open(filepath, 'r', encoding='utf-8') as file:
# 创建CSV读取器
reader = csv.reader(file)
# 将内容存储到列表中
rows = []
for row in reader:
rows.append(row)
# 添加新行
# new_row = ['New Data 1', 'New Data 2'] # 新行的数据
new_row = [database_name, date] # 新行的数据
rows.append(new_row)
# 写入CSV文件
# with open('./database_name.csv', 'w', newline='', encoding='utf-8') as file:
with open(filepath, 'w', newline='', encoding='utf-8') as file:
# 创建CSV写入器
writer = csv.writer(file)
# 写入所有行
writer.writerows(rows)
# close the file to save the data.
file.close()
return None