-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Simple TSV output format #645
Conversation
The proposed implementation of The successes are illustrated by the following "#-annotated" transcript:
The failure is illustrated by the following:
(*) Apart from the fact that we requested two fields but got three, this result can be deemed to be incorrect because the IANA standard states:
jq thus has a choice: to raise an error condition, or to retain the embedded escaped tab as such, i.e. in this case, to produce the six-character string:
Raising an error condition here would be aggravating at best. Since the two-character sequence "\t" is often used to denote an embedded tab, not least within JSON itself, I believe that alternative is the better choice here. (There is no need to consider here the case of embedded but unescaped tabs as they are not valid in JSON.) |
That is a good point. I think replacing tab with |
escape_string escapes single characters, e.g. That is,
|
I understand. My apologies, I saw |
Can we merge this codepath with the |
@nicowilliams - In the interests of simplicity and brevity, the following has much to recommend it, except perhaps for the name:
Is there a way to add "@TSV" defined as above? |
That would probably be a good idea. However I'm not very good at C, so I took the simple, and direct, approach with this. |
@pkoppstein |
@rory This is my proposed change:
|
@nicowilliams wrote:
Perhaps you were intending this remark for someone else. I merely observed that it seems to me that all that is needed to support
except that I don't know how to use "def" to define The differences between |
@pkoppstein Ah, you're right that Here's a new patch:
Also included, for paranoia:
|
That produces:
which I think is what you meant. And it shows that Hmmm, we don't have |
I've added a
@tsv
output filter by copying the@csv
filter. It outputs into TSV (tab-separated values) file. Some people have asked for this on #48 .I haven't done anything with string escaping, because (a) I'm not sure how to use
escape_string
, and (b) I'm unsure what "the standard" TSV approach is. I think many unix tools don't escape tabs.