GithubHelp home page GithubHelp logo

datatable's Introduction

datatable

import (
    "fmt"
    "github.com/BlueStorm001/datatable"
)
func main() {
    var rows = []map[string]interface{}{
        {"id": 5, "code": "BJS", "name": "CN", "money": 1.23},
        {"id": 2, "code": "BJS", "name": "CN", "money": 2.21},
        {"id": 3, "code": "SHA", "name": "CN", "money": 1.26},
        {"id": 4, "code": "NYC", "name": "US", "money": 3.99},
        {"id": 7, "code": "MEL", "name": "US", "money": 3.99},
        {"id": 1, "code": "", "name": "CN", "money": 2.99},
    }
    for i := 10; i < 9999; i++ {
        rows = append(rows, map[string]interface{}{"id": i, "code": "BJS", "name": "CN", "money": 1.23})
    }
    
    dt := datatable.New(rows)

    // Where 条件匹配 (a=1 and b=2) or (c=2 and d=3) Condition match
    table := dt.Where("Text='CN' and (code='BJS' or code='SHA')").OrderBy("id") 
    for i, row := range table.Rows {
        fmt.Println(i,row)
    }
    
    // 使用模糊搜索 
    // Use fuzzy search
    table = dt.Like("name='CN%' and money=1.2%").OrderBy("id desc")
    
    // 使用正则表达式 
    // Use regular expressions
    table = dt.Find("code='[A-Z]{3}'").OrderBy("id desc")
    
    // 分组
    // Group
    table = dt.GroupBy("name")
    for i, row := range table.Rows {
        name := row["name"].(string)
        newTable := dt.Where("name='" + name + "' and (code='BJS' or code='SHA')").OrderBy("id") //[id asc , name desc]...
        fmt.Println(newTable)
    }
   
}

datatable's People

Contributors

bluestorm001 avatar

Stargazers

 avatar

Watchers

 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.