一、使用pdfplumber截取pdf文档中的信息
import pdfplumber
import pandas as pd
# 读取PDF文件中的信息
with pdfplumber.open("FS.pdf") as pdf:
page01 = pdf.pages[1] # 指定页码
text = page01.extract_text()
holdings_index1 = text.index('Top')
holdings_index2 = text.index('The information provided')
holdings = text[holdings_index1:holdings_index2]
holdings_no_title = holdings.replace('Top 10 Holdings', '')
holdings_splited = holdings_no_title.split('\n')
holding_name = []
holding_data = []
for i in range(1, 11):
data = holdings_splited[i][-5:]
name = holdings_splited[i][0:-6]
holding_data.append(data)
holding_name.append(name)
二、读取excel文件中的数据
xls = pd.ExcelFile('GreatLink_Top_10_holdings.xlsx')
sheets = {}
使用 pd.ExcelFile('GreatLink_Top_10_holdings.xlsx')
创建一个 ExcelFile 对象。这个对象表示待读取的