0.0
No release in over 3 years
Low commit activity in last 3 years
Simple solution to export csv file.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

Csv exporter

This is the simple solutuon to export csv file from array/ActiveRecord collection.

Installation

Simply add into Gemfile:

gem 'csv_exporter'

After that you can use .csv_export method in your own project.

csv_export(hash_or_array_of_fields, filename)

Usage

####Scope

######Array of fields

User.my_custom_scope.csv_export([:name, :email, :age])
User.my_custom_scope.csv_export([:name, :email, :age], 'users.csv')

######Hash of fields

User.my_custom_scope.csv_export('User name' => :name, 'User email' => :emal, 'Years old' => :age)
User.my_custom_scope.csv_export({ 'User name' => :name, 'User email' => :emal, 'Years old' => :age }, 'users.csv')

####Array/Hash

For arrays of arrays or hashes just use .csv_export method without any parameters

[
  ['Name', 'Age', 'Sex'],
  ['Mike', 23, 'M'],
  ['Helga', 26, 'F']
].csv_export


[
  { first: 1, second: 2, third: 3 },
  { first: 4, second: 5, third: 6 },
  { first: 'a', second: 'b', third: 'c' }
].csv_export