csvson

package module
v0.0.0-...-e1b4704 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 9 Imported by: 0

README

csvson

Handfull package for converting CSV files to JSON structed files in Golang directly.

how to use:

  • download package using command below:
    go get "github.com/KyloReneo/csvson"
    
  • import the package:
    import "github.com/KyloReneo/csvson"
    
  • convert csv to json directly:
    csvson.CSVToJSON("./csv-file-path")
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttributesIndex

func AttributesIndex(attribute string) (string, int)

Finds attribute and index of nested attributes and returns them

func CSV2Slice

func CSV2Slice(CSVPath string) ([][]string, error)

Recives path of CSV file as input and returns a sliced array of rows

func CSVRowsToMap

func CSVRowsToMap(header []string, values [][]string) []map[string]interface{}

Creates a map of CSV headers and values

func CSVToJSON

func CSVToJSON(path string)

func CheckError

func CheckError(err error)

Checking errors

func JSONString

func JSONString(rows [][]string) (string, error)

func MapToString

func MapToString(entries []map[string]interface{}) (string, error)

Recives map of entities and returns json formated result

func OpenCSV

func OpenCSV(path string) (CSVFile *os.File)

Opens the given path and returns the CSV file

func ReadCSV

func ReadCSV(CSVFile *os.File) (CSVRows [][]string)

Reads the CSVFile and returns A 2D string slice of rows

func WriteToJSON

func WriteToJSON(json string)

Creates json file

Types

This section is empty.

Jump to

Keyboard shortcuts

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