1
0
Fork 0
This repository has been archived on 2021-01-06. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
dennogumi.org-archive/_posts/2007-05-24-tab2dokuwiki.markdown

1.2 KiB

author comments date layout slug title wordpress_id categories
einar true 2007-05-24 18:16:18+00:00 page tab2dokuwiki tab2dokuwiki 251
General
Linux

Today I made a simple sed script that converts a tab-delimited text file to a format that can be pasted into a DokuWiki wiki. There is a plugin that permits to read CSV files directly, however:

  • It doesn't support tab-delimited text files;

  • It's incompatible with some plugins (one being DokuTexit, which I need).

Hence the need for this script. To use it, just copy and paste the code (see below) into a new file, make it executable (chmod +x) and then invoke it with

[code lang="bash"] tab2wiki inputfile [/code]

Note that it outputs the result on stdout, so you'll need to redirect it if you want to save.

Without further ado, here's the script (syntax may be off regarding colors):

[code lang='c'] #!/bin/sed -f

tab2wiki - converts any tab-delimited file into a DokuWiki table

First line is treated as header (^)

{ s/\t/| /g s/$/ |/g s/^/| /g s/| / | /g 1s/|/^/g s/^\s\s//g } [/code] *[CSV]: Comma Separated Values