Table include macro - tab-delimited files

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Table include macro - tab-delimited files

brianrepko
My understanding is that one cannot include a tab-delimited file as table data.
I've tried changing separator - and tried an include1 macro as well since include converts tabs to spaces.

Am I missing something? Tables cannot use tabs as a delimiter?

-brian
Reply | Threaded
Open this post in threaded view
|

Re: Table include macro - tab-delimited files

mojavelinux
Administrator
Tables can, in fact, use tabs as a delimiter. (The name of the attribute is separator). The only caveat is that you must specify the value using a literal tab character, not an escape code.

I put the example in a gist so as not to lose the formatting (and to demonstrate it in action)


I'll add an enhancement to Asciidoctor to allow the separator to be specified using the escape code, \t.

[separator=\t]

Cheers,

-Dan


On Mon, Mar 13, 2017 at 3:44 PM, brianrepko [via Asciidoctor :: Discussion] <[hidden email]> wrote:
My understanding is that one cannot include a tab-delimited file as table data.
I've tried changing separator - and tried an include1 macro as well since include converts tabs to spaces.

Am I missing something? Tables cannot use tabs as a delimiter?

-brian


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Table-include-macro-tab-delimited-files-tp5374.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Table include macro - tab-delimited files

brianrepko
Hi Dan,

Thanks for the quick reply. A ticket for allowing `\t` as separator would be great.
In addition, I think a ticket for an include macro option to preserve tabs is also
needed. Tabs are troublesome in regular editors - in order to do what you have
in the gist. However, they are quite common for external example data files
(particularly in bioinformatics). So the combination of separator and include is
what is needed, I feel. You could even bundle that all up in a format="tsv" if it
was common enough.

Thanks again!!
-brian

----- Original message -----
From: "mojavelinux [via Asciidoctor :: Discussion]" <[hidden email]>
To: brianrepko <[hidden email]>
Subject: Re: Table include macro - tab-delimited files
Date: Mon, 13 Mar 2017 21:20:36 -0700 (MST)

Tables can, in fact, use tabs as a delimiter. (The name of the attribute is separator). The only caveat is that you must specify the value using a literal tab character, not an escape code.

I put the example in a gist so as not to lose the formatting (and to demonstrate it in action)


I'll add an enhancement to Asciidoctor to allow the separator to be specified using the escape code, \t.

[separator=\t]

Cheers,

-Dan


On Mon, Mar 13, 2017 at 3:44 PM, brianrepko [via Asciidoctor :: Discussion] <[hidden email]> wrote:
My understanding is that one cannot include a tab-delimited file as table data.
I've tried changing separator - and tried an include1 macro as well since include converts tabs to spaces.

Am I missing something? Tables cannot use tabs as a delimiter?

-brian



If you reply to this email, your message will be added to the discussion below:
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux




If you reply to this email, your message will be added to the discussion below:
To unsubscribe from Table include macro - tab-delimited files, click here.

Reply | Threaded
Open this post in threaded view
|

Re: Table include macro - tab-delimited files

mojavelinux
Administrator

A ticket for allowing `\t` as separator would be great.

See https://github.com/asciidoctor/asciidoctor/issues/2073

-Dan


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Table include macro - tab-delimited files

mojavelinux
Administrator
In reply to this post by brianrepko


I think a ticket for an include macro option to preserve tabs is also
needed.

The include directive does not remove tabs by default. Only if you set the indent attribute on the include directive and set the tabsize document attribute will tabs be expanded, but that's intended for use with source code, not tsv.

Cheers,

-Dan


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Table include macro - tab-delimited files

mojavelinux
Administrator
In reply to this post by brianrepko


You could even bundle that all up in a format="tsv" if it
was common enough

Adding the tsv attribute does seem intriguing. I'll add a note to the open issue about it.

-Dan


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Table include macro - tab-delimited files

brianrepko
In reply to this post by mojavelinux
Thanks Dan - I was clearly reading old asciidoc doc (thus my mention of the `include1` macro above).
All great to know, I'll embedding the tab character in the document as separator for now and will watch the issue above (thanks for creating that).
Reply | Threaded
Open this post in threaded view
|

Re: Table include macro - tab-delimited files

mojavelinux
Administrator

On Tue, Mar 14, 2017 at 6:40 PM, brianrepko [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thanks Dan - I was clearly reading old asciidoc doc (thus my mention of the `include1` macro above).

Ah. Yeah, you want to be here: http://asciidoctor.org/docs/user-manual/


We probably need to call out how to do tab-separated data, though. That information is currently missing.

-Dan


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

+1 Re: Table include macro - tab-delimited files

sturt
+1.

Serendipity. I tried today including TSV output from MS Excel and found the same requirement.

Best regards, Sturt
Reply | Threaded
Open this post in threaded view
|

Re: +1 Re: Table include macro - tab-delimited files

mojavelinux
Administrator
Sturt,

TSV data is now supported in Asciidoctor 1.5.6.1. Please see http://asciidoctor.org/docs/user-manual/#delimiter-separated-values for details.

Did you have a specific question about this feature?

-Dan

On Mon, Aug 14, 2017 at 8:06 AM, sturt [via Asciidoctor :: Discussion] <[hidden email]> wrote:
+1.

Serendipity. I tried today including TSV output from MS Excel and found the same requirement.

Best regards, Sturt


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Table-include-macro-tab-delimited-files-tp5374p5846.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: +1 Re: Table include macro - tab-delimited files

sturt
Hi Dan,

Thank you for responding so quickly.

When including a TSV file, how could we force a new row (not only a new cell) at the end of a data line?

INTENT:
My specific intent was to have the tsv included without modification, no wrap, in monospace, with the columns lining up, looking like a formatted datafile, not a gridded table .

SOLUTION:
My final literal include below gave: monospace formatting, not lined up, without modification, which was sufficient for this dataset.
----
include::{datadir}data-7-cols-last-col-empty.txt[]
----

WORKING AS DESIGNED:
The cause of my original comment in this thread was my data.
It had an empty ending column, which therefore ended in a tab, making a "ragged table".

Therefore AsciiDoc is working as described in http://asciidoctor.org/docs/user-manual/#csv-and-tsv

The tsv include below works if I have "" as the last cell value of the data line, which I'll use in other circumstances.

[%header, format=tsv]
|===
include::{datadir}data-7-cols-empty-cells-as-double-quotes.txt[]
|===

Thanks again for your previous response and great work on AsciiDoc.

Best regards, Sturt.