https://github.com/bearaujus/bdatamatrix
Structured Tabular Data Management in Go
https://github.com/bearaujus/bdatamatrix
data go golang matrix
Last synced: 5 months ago
JSON representation
Structured Tabular Data Management in Go
- Host: GitHub
- URL: https://github.com/bearaujus/bdatamatrix
- Owner: bearaujus
- License: mit
- Created: 2025-02-21T15:40:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-11-01T10:57:38.000Z (8 months ago)
- Last Synced: 2025-11-22T18:21:44.058Z (7 months ago)
- Topics: data, go, golang, matrix
- Language: Go
- Homepage: https://github.com/bearaujus/bdatamatrix
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BDataMatrix - Structured Tabular Data Management in Go
[](LICENSE)
[](https://goreportcard.com/report/github.com/bearaujus/bdatamatrix)
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:
```sh
go get github.com/bearaujus/bdatamatrix
```
## Import
```go
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:
```go
matrix, err := bdatamatrix.New("ID", "Name", "Age")
if err != nil {
log.Fatal(err)
}
```
Create a matrix with predefined data:
```go
rows := [][]string{
{"1", "Alice", "30"},
{"2", "Bob", "25"},
}
matrix, err := bdatamatrix.NewWithData(rows, "ID", "Name", "Age")
if err != nil {
log.Fatal(err)
}
```
### 2. Adding and Querying Rows
```go
_ = matrix.AddRow("3", "Charlie", "35")
query := bdatamatrix.FindRowsQuery{
Column: "Name",
Operator: bdatamatrix.OperatorEquals,
CaseInsensitive: true,
Values: []string{"Alice"},
}
result, err := matrix.FindRows(query)
if err != nil {
log.Fatal(err)
}
fmt.Println("Matched rows:", result)
```
### 3. Exporting Data
Export as CSV:
```go
csvOutput := matrix.ToCSV(true)
_ = csvOutput.Write("output.csv", 0644)
```
Export as JSON:
```go
jsonOutput := matrix.ToJSON(true, false)
_ = jsonOutput.Write("output.json", 0644)
```
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/bearaujus/bdatamatrix/blob/master/LICENSE) file for details.