# Path: kquant_data/config.py
# __CONFIG_H5_FUT_SECTOR_DIR__ = os.path.join(__CONFIG_H5_FUT_DIR__, 'sectorconstituent')
# 
# Path: kquant_data/wind/wset.py
# def write_constituent(path, df):
#     df.to_csv(path, encoding='utf-8-sig', date_format='%Y-%m-%d', index=False)
# 
# def read_constituent(path):
#     """
#     读取板块文件
#     :param path:
#     :return:
#     """
#     try:
#         df = pd.read_csv(path, encoding='utf-8-sig', parse_dates=True)
#     except Exception as e:
#         return None
#     try:
#         df['date'] = pd.to_datetime(df['date'])
#     except KeyError:
#         pass
#     return df


import os
import sys
import pandas as pd
from kquant_data.config import __CONFIG_H5_FUT_SECTOR_DIR__
from kquant_data.wind.wset import write_constituent, read_constituent
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
上期所下有原油交易中心的合约sc
sc在上市之前仿真了很久，导致下载的文件中有大量的仿真合约，需要清理
"""

# 解决Python 3.6的pandas不支持中文路径的问题
print(sys.getfilesystemencoding())  # 查看修改前的
try:
    sys._enablelegacywindowsfsencoding()  # 修改
    print(sys.getfilesystemencoding())  # 查看修改后的
except:
    pass

if __name__ == '__main__':

# Path: kquant_data/config.py
# __CONFIG_H5_FUT_SECTOR_DIR__ = os.path.join(__CONFIG_H5_FUT_DIR__, 'sectorconstituent')
# 
# Path: kquant_data/wind/wset.py
# def write_constituent(path, df):
#     df.to_csv(path, encoding='utf-8-sig', date_format='%Y-%m-%d', index=False)
# 
# def read_constituent(path):
#     """
#     读取板块文件
#     :param path:
#     :return:
#     """
#     try:
#         df = pd.read_csv(path, encoding='utf-8-sig', parse_dates=True)
#     except Exception as e:
#         return None
#     try:
#         df['date'] = pd.to_datetime(df['date'])
#     except KeyError:
#         pass
#     return df


# Path: demo_future/C03_update_sector.py
import os
import sys
import pandas as pd
from kquant_data.config import __CONFIG_H5_FUT_SECTOR_DIR__
from kquant_data.wind.wset import write_constituent, read_constituent

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
上期所下有原油交易中心的合约sc
sc在上市之前仿真了很久，导致下载的文件中有大量的仿真合约，需要清理
"""

# 解决Python 3.6的pandas不支持中文路径的问题
print(sys.getfilesystemencoding())  # 查看修改前的
try:
    sys._enablelegacywindowsfsencoding()  # 修改
    print(sys.getfilesystemencoding())  # 查看修改后的
except:
    pass

if __name__ == '__main__':

    path = os.path.join(__CONFIG_H5_FUT_SECTOR_DIR__, "上期所全部品种")