Header-based record columns & 'to.object' function addition #141

Merged
merged 6 commits into from Feb 10, 2014

Projects

None yet

3 participants

@Joeasaurus
Contributor

Commit messages should explain it all. I'm not sure if I did this right though since I'm new to git.

Joeasaurus added some commits Dec 6, 2013
@Joeasaurus Joeasaurus Added header-record based column arrangement.
You can now pass {"header":true} as an option argument to to.array(). It
will return an array of objects the same as using {"columns":[..]}
would, except it uses the header record to obtain the column names.
1e22618
@Joeasaurus Joeasaurus Added to.object function.
'to.object' does the exact same thing as to.array, but puts the records
in an object{} instead of an array[]. It has a mandatory option
requirement of 'objname' which is the column/header to use to name the
records by in the resulting object.

Example:
csv: "Name,Age\nJoe,21"
objname: "Name"
output: { Joe: {Name: 'Joe', Age: '21'}
a4f0fa9
@Joeasaurus Joeasaurus Added trim() to the title names in to.object 52f2825
@wdavidw
Owner
wdavidw commented Dec 9, 2013

I need tests and a sample. I have difficulties to understand what it's doing.

@Joeasaurus
Contributor

I'm not fluent with coffeescript at all, so it will take me a little while to get you some tests. I will sort out examples though :)

@wdavidw
Owner
wdavidw commented Dec 9, 2013

feel free to do it in javascript, i really don't mind converting, otherwise it's the occasion to try

@Joeasaurus
Contributor

Ok all features have examples and tests now I think.

@nicosommi

this is a very nice feature, if you let me in this case i will suggest adding a dependency to underscore and use _.object since it just has a 10 line implementation

@wdavidw wdavidw merged commit a750619 into wdavidw:master Feb 10, 2014

1 check passed

Details default The Travis CI build passed
@wdavidw
Owner
wdavidw commented Feb 10, 2014

Why/where would do need to a this dependency? Personnaly, i'll rather import the 10 lines than referencing an external project, even underscore.

@wdavidw wdavidw added a commit that referenced this pull request Mar 14, 2014
@wdavidw Push update from #141 1811538
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment