import pandas as pd
import os
pd.set_option('expand_frame_repr', False) # 当列太多时显示完整
# =====导入浦发银行(sh600000)的历史日线数据
df = pd.read_csv(
r'C:\Users\Simons\Desktop\xbx_stock_2019\data\basic-trading-data\stock_data\sh600004.csv',
encoding='gbk',
skiprows=1, parse_dates=['交易日期']
)
# =====批量导入A股所有股票的历史日线数据
# 系统自带函数os.walk,用于遍历文件夹中的所有文件,os是python自带的系统库
# 演示os.walk
# file location存储我们要读取的数据的文件夹绝对路径
file_location = r'C:\Users\Simons\Desktop\xbx_stock_2019\data\basic-trading-data\stock_data'
# for root, dirs, files in os.walk(file_location):
# # root输出文件夹,dirs输出root下所有的文件夹,files输出root下的所有的文件
# print('当前文件夹:', root)
# print('包含的文件夹:', dirs)
# print('包含的文件:', files)
# print()
# 批量读取文件名称
# file_list = []
# for root, dirs, files in os.walk(file_location):
# for filename in files:
# if filename.endswith('.csv'):
# file_path = os.path.join(root, filename)
# file_path = os.path.abspath(file_path)