Named csv reader for go

Named csv reader

Package named csv reader provides methods to easly read csv files and parse columsn to basic types.

This package is not a CSV parser, it uses the encodig/csv reader to parse the csv file.

Installation

go get github.com/dylanvgils/namedcsvreader

Examples

CSV file with headers

Read csv file using the headers in the csv file.

file, err := os.Open("testdata/valid.csv")
if err != nil {
    panic(err)
}

for record := range namedcsvreader.NewReader(file).Read() {
    fmt.Printf("Name: %s; Age: %d\n", record.GetString("name"), record.GetInt("age"))
}

// Output:
// Name: Colorado Leon; Age: 26
// Name: Rajah Fletcher; Age: 47
// Name: Tobias Snow; Age: 16
// Name: Jared Finch; Age: 19

CSV file without headers

Read a csv file that does not contain headers, by specifying your own.

file, err := os.Open("testdata/valid_without_headers.csv")
if err != nil {
    panic(err)
}

reader := namedcsvreader.NewReader(file).
    WithHeaders("name", "age")

for record := range reader.Read() {
    fmt.Printf("Name: %s; Age: %d\n", record.GetString("name"), record.GetInt("age"))
}

// Output:
// Name: Colorado Leon; Age: 26
// Name: Rajah Fletcher; Age: 47
Owner
Dylan van Gils
Software Engineer
Dylan van Gils
Similar Resources

Command line tool for processing client transaction data in CSV format

command line tool for processing client transaction data in CSV format. thank you for looking! build instructions: $ git clone https://github.com/lnit

Oct 29, 2021

Easy to use library and CLI utility to generate Go struct from CSV files.

csv2struct Easy to use library and CLI utility to generate Go struct from CSV files. As a benefit, it's fully compatible with csvutil. So, structs gen

Nov 7, 2022

Smart and simple CSV processing on the command line

csvquote smart and simple CSV processing on the command line Are you looking for a way to process CSV data with standard UNIX shell commands? Are you

Dec 30, 2022

TIled map editor CSV export conversion to C array

tiled2c This tool is very simplistic and is a variation of the one written to convert between Tiled map editor CSV exports and a format for the sega s

Nov 28, 2021

CLI filters the contents of the csv file according to the filters from the another file.

filtercsv CLI filters the contents of the csv file according to the filters from the another file. Made to process big files by a lots of filters. By

Dec 2, 2021

Simple tool to convert a Parquet file to a CSV written in Go/ Golang

Parquet2CSV Parquet2CSV is a simple tool to convert a Parquet file to a CSV written in Go/ Golang Usage: parquet2csv PATH_TO_PARQUET_FILE This will

Nov 3, 2022

From the command line, quickly explore data from a CSV file.

From the command line, quickly explore data from a CSV file.

shallow-explore From the command line, quickly explore data from a CSV file. shallow-explore is a Golang backed command-line tool for iterating over c

Nov 10, 2022

Visualize CSV data in Golang

Golang CSV Viewer Visualize CSV data in Golang Run official example cd official go run . # in another terminal window open http://localhost:8089 bars

Jan 18, 2022

A piece of software that shouldn't need to exist. Processes badly formatted outputs from Morgan Stanley Shareworks into usable CSV files.

A piece of software that shouldn't need to exist.  Processes badly formatted outputs from Morgan Stanley Shareworks into usable CSV files.

Shareworks-munger: A program to process Shareworks reports into Something Usable "Shareworks" is a product of Morgan Stanley which tracks certain kind

Jun 6, 2022
Declarative CLI Version manager. Support Lazy Install and Sharable configuration mechanism named Registry. Switch versions seamlessly

aqua Declarative CLI Version manager. Support Lazy Install and Sharable configuration mechanism named Registry. Switch versions seamlessly. Index Slid

Dec 29, 2022
Command-line tool for listening log file of game named as

Path of Exile Trade Notifier Command-line tool for listening log file of game named as "Path of Exile" and looking for buy message and send it to Tele

Apr 15, 2022
terminal rss reader

TODO Add author field [x] Add Source as own type to support both http sources and file types sources [x] Move Load http call to own method that Load m

Nov 7, 2021
TXQR (Animated QR data transfer) demo reader app for iOS
TXQR (Animated QR data transfer) demo reader app for iOS

TXQR Reader for iOS txqr-reader is a demo app in Swift that reads animated QR code and shows file. Currently it expects file to be an JPEG image. Just

Nov 24, 2022
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.

dasel Dasel (short for data-selector) allows you to query and modify data structures using selector strings. Comparable to jq / yq, but supports JSON,

Jan 2, 2023
A fast diff tool for comparing csv files

csvdiff A fast diff tool for comparing csv files. What is csvdiff? Csvdiff is a difftool to compute changes between two csv files. It is not a traditi

Dec 28, 2022
A simple script to run speedtest(offical) CLI tool and store the results in CSV

PeriodicBW A script made to run official speedtest.net binary periodically and store the results in a CSV file Installation Get the official speedtest

Aug 10, 2021
Command-line tool to load csv and excel (xlsx) files and run sql commands
Command-line tool to load csv and excel (xlsx) files and run sql commands

csv-sql supports loading and saving results as CSV and XLSX files with data processing with SQLite compatible sql commands including joins.

Nov 2, 2022
CLI tool to rank proposals according to Majority Judgment, from an input CSV
CLI tool to rank proposals according to Majority Judgment, from an input CSV

Majority Judgment CLI tool WORK IN PROGRESS Although the core mechanics are here and ranking does work, the features described in this README are not

Sep 10, 2022
A simple command line for convert CSV in JSON
A simple command line for convert CSV in JSON

C2J A simple command line for convert CSV in JSON list of objects based on header. Install With Go 1.17 or higher: go install github.com/edermanoel94/

Dec 14, 2022