Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array.tsv(), closes #279 #282

Merged
merged 1 commit into from
Sep 15, 2019
Merged

array.tsv(), closes #279 #282

merged 1 commit into from
Sep 15, 2019

Conversation

odino
Copy link
Collaborator

@odino odino commented Sep 15, 2019

Arrays can now easily be formatted as TSV / CSV content:

array.tsv()
array.tsv(",")

Here are some samples:

⧐  [["LeBron", "James"], ["James", "Harden"]].tsv()
LeBron	James
James	Harden

⧐  [{"name": "Lebron", "last": "James", "jersey": 23}, {"name": "James", "last": "Harden"}].tsv("\t", ["name", "last", "jersey", "additional_key"])
name	last	jersey	additional_key
Lebron	James	23	null
James	Harden	null	null

There is some complexity in this function due to the fact that
we have to support custom headers, as well as the fact that we
can both format arrays of objects as well as hashes.

Arrays can now easily be formatted as TSV / CSV content:

```
array.tsv()
array.tsv(",")
```

Here are some samples:

```
⧐  [["LeBron", "James"], ["James", "Harden"]].tsv()
LeBron	James
James	Harden

⧐  [{"name": "Lebron", "last": "James", "jersey": 23}, {"name": "James", "last": "Harden"}].tsv("\t", ["name", "last", "jersey", "additional_key"])
name	last	jersey	additional_key
Lebron	James	23	null
James	Harden	null	null
```

There is some complexity in this function due to the fact that
we have to support custom headers, as well as the fact that we
can both format arrays of objects as well as hashes.
@odino odino added the enhancement New feature or request label Sep 15, 2019
@odino odino added this to the 1.8.x milestone Sep 15, 2019
@odino odino merged commit 15499a4 into 1.8.x Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant