需求
批量上载本地 excel 中存储数据至数据库。
本地excel中数据为二维结构,需先转换为一维表。
环境、工具、技术路线
Win7
Python 3.6
Spyder
流程图
代码
# _*_ conding: utf-8 _*_
'''
getConfig.py
从配置文件中读取数据
'''
from configparser import ConfigParser
class Conf():
def __init__(self, path):
self._path = path
def getInfo(self, sec, U, P, ip, port, db):
fil = ConfigParser()
fil.read(self._path)
return (fil.get(sec, U),
fil.get(sec, P),
fil.get(sec, ip),
fil.get(sec, port),
fil.get(sec, db))
# _*_ coding: utf-8 _*_
'''
getDoc.py
1.获取路径下的文件
2.获取指定【关键词】筛选的文件
'''
import os
class Doc():
def __init__(self, path):
self._path = path
def getAll(self):
return os.listdir(self._path)
def getSome(self, key):
return [f for f in os.listdir(self._path) if key in f]
# _*_ coding: utf-8 _*_
'''
up_sp_cash.py
- 上载消费和现金
'''