Giter Site home page Giter Site logo

csv_find's Introduction

CSV Find v1.0.0

Let's just get this out of the way: this gem is 60% an academic exercise in quickly navigating through a CSV without actually using the Ruby CSV library for much of it. How do we do that? We shell out to the system and use some tools to chomp the file down to the pieces we are looking for. It's actually pretty fast at finding arbitrary records in even very large CSV files without being crazy memory intensive. That's probably why I started writing this in the first place.

I have used this code in production, you can too, most of the time you probably want a solution backed by the CSV library. I don't think I have done any benchmarking against it. You can see how to do some of this in a more normal way over here:

https://stackoverflow.com/questions/9599568/how-to-find-a-specific-row-in-csv/33849136

Usage

Install

gem install csv_find

Add it to a class.

class People
  include CsvFind
  csv_file('path/to/people.csv', {optional: 'csv_configurations'})
end

Now you have a setters and getters based on the headers of the csv file.

Methods

Yourclass.new
Yourclass.find(line_number)
Yourclass.where(header1: 'value', header2: 'value')
Yourclass.first
Yourclass.last
Yourclass.each { |a| a.method  }

Plus, the Enumerable module is implemented!

License

CSV Find is Copyright © 2020 Mark Platt, Inc. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.

csv_find's People

Contributors

mrkplt avatar

Stargazers

Tom Scott avatar

Watchers

 avatar  avatar

csv_find's Issues

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.