Coder Social home page Coder Social logo

project_access_formular's Introduction

Project_work_获取jx_bonus_formular Beta 1.0

  1. 假设客户的数据库市本地连结,数据库假设是mssql
  2. 本专案建立在 Project_work_获取數據与导出excel 1.0
  3. beta 1.0 初期建立获取与资料清洁,後续完善回写数据库、导出excel 表
  4. 利用正则表达获取中文字

导入基本数据package

import pandas as pd import pyodbc import re

建立与数据库连接

    conn = pyodbc.connect(  
        'Driver={SQL Server Native Client 10.0};'  
        'Server=.;'  
        'Database=gshm_jx;'  
        'Trusted_Connection=yes;'  
    )  

    #{SQL Server Native Client 10.0} => mssql2008  

数据处理与清洗

    df_formular['formular']   
    df_formular_text = df_formular['formular'].iloc[590]  

正则表达获取中文字 并且 回写 sql query 的结果

    text = re.sub("[A-Za-z0-9\!\%\[\]\,\。\+\-\*\)\(]", " ", df_formular_text).split(' ')

    for i in range(number):  
    df_parameter_pd = df_parameter[df_parameter['parameter_name'] == text[i]]  
    df_formula_name = text[i]  
    df_formula_name  
    if df_formula_name == ''or df_formula_name == '.':  
        pass   
    else :  
        df_formula_value = df_parameter_pd['para_value'].iloc[0]  
        df_formular_text = df_formular_text.replace(df_formula_name, str(df_formula_value))  

## 計算公式結果(函數 eval() )

    eval(df_formular_text)
    

project_access_formular's People

Contributors

smopthy avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.