import pandas as pd
from datetime import datetime
def generate_questions():
excel_path =
df = pd.read_excel(excel_path)
theme = []
time_list = []
tag1 = []
tag2 = []
tag3 = []
word_count = 800
questions = []
for index, row in df.iterrows():
if isinstance(row['时间'], datetime):
time_str = row['时间'].strftime("%Y%m%d%H%M")
else:
try:
time_str = datetime.strptime(str(row['时间']), "%Y-%m-%d %H:%M").strftime("%Y%m%d%H%M")
except:
time_str = str(row['时间'])
time_list.append(time_str)
theme.append(str(row['主题']))
tag1.append(str(row['标签1']) if pd.notna(row['标签1']) else "")
tag2.append(str(row['标签2']) if pd.notna(row['标签2']) else "")
tag3.append(str(row['标签3']) if pd.notna(row['标签3']) else "")
for i in range(len(theme)):
tags = [t for t in [tag1[i], tag2[i], tag3[i]] if t]
tags_str = "、".join(tags)
question = (
)
questions.append(question)
return questions
if __name__ == "__main__":
generated_questions = generate_questions()
for i in range(len(generated_questions)):
print(f"第{i + 1}个提问:")
print(generated_questions[i])
print("-" * 50)