Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Structured Tabular Data Management in Go

License

NotificationsYou must be signed in to change notification settings

bearaujus/bdatamatrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LicenseGo Report Card

BDataMatrix is a lightweight Go library for managing structured tabular data efficiently. It provides functions to add, update, delete, sort, and query data, along with various export options such as CSV, TSV, JSON, and YAML.

Installation

To install BDataMatrix, run:

go get github.com/bearaujus/bdatamatrix

Import

import"github.com/bearaujus/bdatamatrix"

Features

  • Create structured tabular data with defined headers.
  • Add, update, delete, and search rows efficiently.
  • Export data to CSV, TSV, JSON, YAML, or custom formats.
  • Track header indices for optimized querying.
  • Support for case-insensitive searching.

Usage

1. Creating a Matrix

Create a new matrix with headers:

matrix,err:=bdatamatrix.New("ID","Name","Age")iferr!=nil {log.Fatal(err)}

Create a matrix with predefined data:

rows:= [][]string{    {"1","Alice","30"},    {"2","Bob","25"},}matrix,err:=bdatamatrix.NewWithData(rows,"ID","Name","Age")iferr!=nil {log.Fatal(err)}

2. Adding and Querying Rows

_=matrix.AddRow("3","Charlie","35")query:= bdatamatrix.FindRowsQuery{Column:"Name",Operator:bdatamatrix.OperatorEquals,CaseInsensitive:true,Values:          []string{"Alice"},}result,err:=matrix.FindRows(query)iferr!=nil {log.Fatal(err)}fmt.Println("Matched rows:",result)

3. Exporting Data

Export as CSV:

csvOutput:=matrix.ToCSV(true)_=csvOutput.Write("output.csv",0644)

Export as JSON:

jsonOutput:=matrix.ToJSON(true,false)_=jsonOutput.Write("output.json",0644)

License

This project is licensed under the MIT License - see theLICENSE file for details.


[8]ページ先頭

©2009-2025 Movatter.jp