• Stars
    star
    174
  • Rank 219,104 (Top 5 %)
  • Language
    Ruby
  • License
    Other
  • Created almost 15 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

FasterCSV is CSV, but faster, smaller, and cleaner.

Read Me¶ ↑

by James Edward Gray II

Description¶ ↑

Welcome to FasterCSV.

FasterCSV is intended as a replacement to Ruby’s standard CSV library. It was designed to address concerns users of that library had and it has three primary goals:

  1. Be significantly faster than CSV while remaining a pure Ruby library.

  2. Use a smaller and easier to maintain code base. (FasterCSV is larger now, but considerably richer in features. The parsing core remains quite small.)

  3. Improve on the CSV interface.

Obviously, the last one is subjective. If you love CSV’s interface, odds are good this one won’t suit you. I did try to defer to that interface whenever I didn’t have a compelling reason to change it though, so hopefully this won’t be too radically different.

What’s Different From CSV?¶ ↑

I’m sure I’ll miss something, but I’ll try to mention most of the major differences I am aware of, to help others quickly get up to speed:

CSV Parsing¶ ↑

  • FasterCSV has a stricter parser and will throw MalformedCSVErrors on problematic data.

  • FasterCSV has a less liberal idea of a line ending than CSV. What you set as the :row_sep is law.

  • CSV returns empty lines as [nil]. FasterCSV calls them [].

  • FasterCSV has a much faster parser.

Interface¶ ↑

  • FasterCSV uses Hash-style parameters to set options.

  • FasterCSV does not have generate_row() or parse_row() from CSV.

  • FasterCSV does not have CSV’s Reader and Writer classes.

  • FasterCSV::open() is more like Ruby’s open() than CSV::open().

  • FasterCSV objects support most standard IO methods.

  • FasterCSV has a new() method used to wrap objects like String and IO for reading and writing.

  • FasterCSV::generate() is different from CSV::generate().

  • FasterCSV does not support partial reads. It works line-by-line.

  • FasterCSV does not allow the instance methods to override the separators for performance reasons. They must be set in the constructor.

If you use this library and find yourself missing any functionality I have trimmed, please let me know.

Documentation¶ ↑

See FasterCSV for documentation.

Installing¶ ↑

See the INSTALL file for instructions.

What is CSV, really?¶ ↑

FasterCSV maintains a pretty strict definition of CSV taken directly from the RFC. I relax the rules in only one place and that is to make using this library easier. FasterCSV will parse all valid CSV.

What you don’t want to do is feed FasterCSV invalid CSV. Because of the way the CSV format works, it’s common for a parser to need to read until the end of the file to be sure a field is invalid. This eats a lot of time and memory.

Luckily, when working with invalid CSV, Ruby’s built-in methods will almost always be superior in every way. For example, parsing non-quoted fields is as easy as:

data.split(",")

Questions and/or Comments¶ ↑

Feel free to email James Edward Gray II with any questions.

More Repositories

1

highline

A higher level command-line oriented interface.
Ruby
1,284
star
2

oklahoma_mixer

An full featured and robust FFI interface to Tokyo Cabinet.
Ruby
57
star
3

hanabi_umbrella

The sample application for Paul Dawson and James Gray's Lonestar Elixir 2017 talk: The NeverEnding Application.
Elixir
53
star
4

simulations

Some simulations using Elixir processes.
Elixir
44
star
5

dotfiles

My personal configuration heaven.
YASnippet
41
star
6

rrdb

A simple Ruby wrapper for RRDtool backed databases.
Ruby
38
star
7

broadsides

The application for Ruby Programming Challenge for Newbies #7 in March 2010
Ruby
23
star
8

signal_lamp

A simple tool for decoupling Ruby object systems.
Ruby
17
star
9

go_gtp

I simple wrapper for the Go Text Protocol
Ruby
14
star
10

rurses

A more Ruby style wrapper over ncurses.
Ruby
12
star
11

peril

A Jeopardy application built with Ruby on Rails
Ruby
12
star
12

advent_of_code_2016

My solutions to the 2016 Advent of Code problems: http://adventofcode.com/
Elixir
11
star
13

better_bj

A rewrite of ara's bj to make it fit in better with modern Rails
Ruby
10
star
14

rubyquiz.com

The original Ruby Quiz site.
10
star
15

browser_captcha

A CAPTCHA system for the browser instead of the user
Ruby
9
star
16

bird_of_paradise

A command-line Twitter client as an example of how to build a curses application.
Ruby
8
star
17

release_training_elixirconf_2019

https://elixirconf.com/2019/training-classes/7
C
8
star
18

canvas

A library for building simple GUI canvases to draw on.
Elixir
7
star
19

advent_of_code_2018

https://adventofcode.com/
Elixir
7
star
20

land_of_emacs_lisp

A reworking of some Land of Lisp examples in Emacs Lisp
Emacs Lisp
6
star
21

shared_room

An experiment with Scenic and multiple players
Elixir
6
star
22

icfp12

Ruby
5
star
23

genetic_algorithms_in_elixir

Working through this book: https://pragprog.com/titles/smgaelixir/genetic-algorithms-in-elixir/
Elixir
5
star
24

fictional_work.tmbundle

The start of a fiction bundle for TextMate from my Prag Pub article
5
star
25

advent_of_code_2015

My solutions for http://adventofcode.com/ in 2015
Ruby
4
star
26

sim_frost

A solution to Ruby Quiz #117
4
star
27

advent_of_code_2017

My solutions for http://adventofcode.com/2017
Elixir
4
star
28

warehouse_keeper

A Sokoban recreation using Ruby Gosu.
Ruby
4
star
29

nand2tetris

SPOILER ALERT: Don't dig into these files if you don't want to see solutions!
Ruby
4
star
30

wig-wug

An unofficial simulator for the first homework assignment (August issue) in The Rubyist.
Ruby
4
star
31

the_toy_robot

My thoughts on The Toy Robot programming challenge.
Elixir
4
star
32

mungr

A Ruby DSL for building data munging scripts
Ruby
4
star
33

chat_app

The code for my Denver Erlang and Elixir Meetup presentation in 2021.
Elixir
3
star
34

advent_of_code_2019

Solutions to the 2019 problems from https://adventofcode.com/
Elixir
3
star
35

haunted_house

This is a Ruby wrapper around the ISY-99i's (a home automation controller) REST interface.
Ruby
3
star
36

the_verse

The TradeWars game I've always dreamed of creating!
Elixir
3
star
37

advent_of_code_2020

https://adventofcode.com/2020
Elixir
3
star
38

incendiary_locator

A Minesweeper clone in Elm
Elm
3
star
39

nested_comments

This was the problem for the first Ruby Quiz Study Group, held March 14th, 2014.
Ruby
2
star
40

jitter

JEG2 on Twitter: The Simplest Twitter Client That Could Possibly Work
2
star
41

global_process_experiments

Elixir
2
star
42

ender

My IRC bot that seems to be perpetually under development
2
star
43

digital_ocean_explorations

Exploring the DigitalOcean API in Elixir
Elixir
2
star
44

live_chart

A joint experiment with @piisalie to generate live charts in Elm from Phoenix channel data
Elixir
2
star
45

tiny_tracer

Experiments with a simpler solution to the 2018 ICFP programming contest
Elixir
2
star
46

hitting_rock_bottom

These are two solutions to PuzzleNode's #11 problem that were discussed in detail in Rubies in the Rough
Ruby
2
star
47

photobooth

My toy photobooth application.
Elixir
2
star
48

icfp-2011

Our 2011 entry
Ruby
2
star
49

ipsc_2014

Our code for the 2014 IPSC contest: http://ipsc.ksp.sk/
Lua
1
star
50

daves_no_test_challenge

Solving an IPSC problem without tests.
Ruby
1
star
51

its_magic

An experiment in testing the effectiveness of Magic decks.
Elixir
1
star
52

ecto_change

An example for the Ecto maintainers
Elixir
1
star
53

crates

Experimenting with Scenic sprites.
Elixir
1
star
54

conf_feed

A sample Rails application
Ruby
1
star
55

old_peeky_blinders

A Web interface on a Raspberry PI that controls the blinds in my office.
Elixir
1
star
56

programmers_stone

JEG2's Elixir blog.
HTML
1
star
57

asciimation

This is the tool used in Codalyzed videos.
Ruby
1
star
58

proper_book_exercises

A sandbox for playing with PropEr as I read the book.
Elixir
1
star
59

icfp_2014

Our contest entry.
Ruby
1
star
60

redeliver

Experiments in an edeliver replacement.
Elixir
1
star
61

random_blades

GM tools for Blades in the Dark.
Elixir
1
star
62

buggy

Playing with some Elixir debugging techniques
Elixir
1
star
63

cluster_test

An experiment in distributed computing
Elixir
1
star
64

ICFP-2009

Our submission for the ICFP 2009 contest
Ruby
1
star
65

concurrecy_exercises

Attempts to solve [these exercises](http://whipperstacker.com/2015/10/05/3-trivial-concurrency-exercises-for-the-confused-newbie-gopher/) in multiple languages.
Elm
1
star
66

pool_experiments

Playing around with different process pooling strategies.
Elixir
1
star
67

advent_of_code_2022

https://adventofcode.com/
Elixir
1
star
68

microservice_patterns

Practicing communication patterns using AWS
Ruby
1
star
69

s3_slideshow

A viewer for my photobooth application.
Elixir
1
star
70

elm_handoff_example

Handing data through a port
Elm
1
star
71

tracing_paper

An experiment with ray tracing.
Elixir
1
star
72

minesweeper_kata

Practicing a kata from the coding dojos at Strange Loop 2015
Ruby
1
star