csvtool

package module
v0.0.0-...-097d63d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 6 Imported by: 0

README

CSV TOOL

Tools to csv file in go language

Installation

  1. You can use the below Go command to install Gin.
go get -u github.com/devMiguelFerrer/csvtool
  1. Import it in your code:
import "github.com/devMiguelFerrer/csvtool"

Features

// function to create new csv tool
func NewCSVTool(fileName string, delimiter rune) CSVTool
// features available
type CSVTool interface {
	ToSQL(tableName, outFileName string, rowsByFile int) error
	RemoveColumn(columns ...string) CSVTool
	SplitCSV(rowsByFile int) error
}

Examples & Usage

// test.csv
ONE;TWO;THREE;FOUR;FIVE;SIX
11;1'2;1'3;1'4;15;16
2'1;2'2;2'3;24;2'5;2'6
31;3'2;3'3;34;3'5;36
// initialize your new csv tool
c := NewCSVTool("test.csv", ';')
// example to split csv
c.SplitCSV(1)
//expected result 2 csv files

// test_01.csv
// ONE;TWO;THREE;FOUR;FIVE;SIX
// 11;1'2;1'3;1'4;15;16
// 2'1;2'2;2'3;24;2'5;2'6

// test_02.csv
// ONE;TWO;THREE;FOUR;FIVE;SIX
// 31;3'2;3'3;34;3'5;36
// examples to create sql files without some columns
c.RemoveColumn("TWO", "THREE").ToSQL("TABLE_SQL", "migration", 2)
//expected result 2 sql files without some columns

// migration_01.sql
// INSERT INTO TABLE_SQL (ONE,FOUR,FIVE,SIX) VALUES
// ('11','1''4','15','16'),
// ('2''1','24','2''5','2''6');

// migration_02.sql
// INSERT INTO TABLE_SQL (ONE,FOUR,FIVE,SIX) VALUES
// ('31','34','3''5','36');

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSVTool

type CSVTool interface {
	ToSQL(tableName, outFileName string, rowsByFile int) error
	RemoveColumn(columns ...string) CSVTool
	SplitCSV(rowsByFile int) error
}

func NewCSVTool

func NewCSVTool(fileName string, delimiter rune) CSVTool

type Column

type Column map[string]int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL