Code Monkey home page Code Monkey logo

csv-tools's Introduction

CSV Tools

Easily extract and access columns from a csv file

FindColumns()

Keep in mind that the indexes in the results have the same sequence as in the find_this variable:

var clean = true
var find_this = []string { "Name", "Date", "Counter" }
var header_row = []string { "Counter", "Name", "Date" }

c, i, _ := csvtools.FindColumns(find_this, header_row, clean)

Result will be:

[ "Name", "Date", "Counter" ], [ 1, 2, 0 ]

find_this

Type: []string
A slice of columns to find. If empty, module will take all the columns available in the header_row

header_row

Type: []string
A row from csv file that you think is a header

clean

Type: bool
Exclude non-existent columns from the results

// clean = false
[ "Name", "NonExistent", "Counter" ], [ 1, -1, 0 ]

// clean = true
[ "Name", "Counter" ], [ 1, 0 ]

IndexByName()

Returns a column index by it's name. If column does not exists, returns -1

i := csvtools.IndexByName(column_name, mapped_list)

column_name

Type: string
Name of the column you are looking for

mapped_list

Type: map[string]int
A row from csv file that you consider a header

csv-tools's People

Contributors

tpkn avatar

Watchers

James Cloos avatar  avatar

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.