AI自动文献综述——python先把知网的文献转excel
第一步 Refworks转excel
下载以后是个txt文件,
帮我把这个txt文件转excel,用函数形式来写便于我后期整理成软件
提取 其中的 标题,作者,单位,关键词,摘要。
分别存入excel列。
import re
import pandas as pd
def extract_and_convert(txt_file_path, output_excel_path):
with open(txt_file_path, 'r', encoding='utf-8') as file:
content = file.read()
# Regular expression patterns for each section
patterns = {
"标题": r"T1\s+(.+?)\n",
"作者": r"A1\s+(.+?)\n",
"单位": r"AD\s+(.+?)\n",
"关键词": r"