lzakharov / csv2md

Command line tool for converting CSV files into Markdown tables.
MIT License
102 stars 8 forks source link

Specify Tab delimiter #13

Closed nickybpm closed 10 months ago

nickybpm commented 10 months ago

I'm workign with some "TSV" (tab delimited) files. I haven't figured out how to specify tab as a delimiter, since it's not really possible to type a tab into my shell. Is there some way to do it?

lzakharov commented 10 months ago

Yes, sure. You can pass your custom delimiter via -d (or --delimiter) flag. You can run csv2md -h to see more information about the available options.

nickybpm commented 10 months ago

Thank you for the reply. I understand that there is the -d flag, but I don’t know how I can use that to set the delimiter to be Tab, since Tab is a non-printable character. I can’t type a character to represent it.

On Wed, Nov 1, 2023, at 7:22 PM, Lev Zakharov wrote:

Yes, sure. You can pass your custom delimiter via -d (or --delimiter) flag. You can run csv2md -h to see more information about the available options.

— Reply to this email directly, view it on GitHub https://github.com/lzakharov/csv2md/issues/13#issuecomment-1789524190, or unsubscribe https://github.com/notifications/unsubscribe-auth/A446SFQ63NXRT37WN2SUXH3YCKOQFAVCNFSM6AAAAAA6ZOJKPWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBZGUZDIMJZGA. You are receiving this because you authored the thread.Message ID: @.***>

nickybpm commented 10 months ago

After researching the matter, I've found it is indeed possible to specify a tab character as an argument on the command line.

For anyone else reading this, the required incantation is:

csv2md -d $'\t' myfile

I tested this in zsh, but I expect it should work in other shells too.

Thanks again for your attention, and a great tool.

nickybpm commented 10 months ago

I tested it and it works with bash as well as zsh. I've dropped a PR (#14) in case you'd like to add it to the docs.

lzakharov commented 10 months ago

Thanks for your research, really appreciate it! Your question is related to working on the command line in general and I've found this explanation useful too.