Code Monkey home page Code Monkey logo

structurama's Introduction

Structurama

Structurama is a lightweight package designed to simplify the process of reading data from Excel files and mapping it to custom Go structs.

Features

  • Easy Integration: Quickly integrate Excel reading capabilities into your Go applications.
  • Custom Struct Mapping: Define a custom Go struct to represent the structure of the data in your Excel file.

Installation

go get -u github.com/PreciousNyasulu/structurama

Quick Start

Custom Struct

Define a custom struct to represent the structure of the data you expect from the Excel file.

type Person struct {
    Id        string `xlsx:"0"`
    FirstName string `xlsx:"1"`
    LastName  string `xlsx:"2"`
    Age       string `xlsx:"3"`
}

How to use:

package main

import (
    "fmt"
    "github.com/PreciousNyasulu/structurama/reader"
)

func main() {
    data, err := structurama.ReadFileDefault("./example.xlsx", Person{}, true)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(data)
}

Here is how you can read file by Sheetname:

func main() {
    data, err := structurama.ReadFileBySheetName("./example.xlsx", Person{}, true,"Sheet1")
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(data)
}

Casting to the Struct

func main() {
    data, err := structurama.ReadFileDefault("./example.xlsx", Person{}, true)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(data)

    peopleData, ok := data.([]Person)
    if ok {
        for _ , item := range peopleData  {
            fmt.Println(item.Id, item.FirstName, item.LastName, item.Age)
        }
    }                         
}

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

Inspiration

tealeg/xlsx - Go library for reading and writing XLSX files.

License

This package is licensed under the MIT License - see the LICENSE file for details.

structurama's People

Contributors

preciousnyasulu avatar

Stargazers

Daelo Namaumbo avatar  avatar Walter Kaunda avatar Steven Nanga avatar Zikani Nyirenda Mwase avatar

Watchers

Zikani Nyirenda Mwase avatar  avatar

structurama's Issues

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.