csv to ascii table conversion?

E

ewaguespack

I am going to build a csv (or colon delimited, or space delimited, etc)
to ascii table converter...


does anything like this already exist?


e.g.:


../xsv2ascii -f /etc/passwd -d ":"
________________________________
| root | x | 0 | 0 | root | /root | /bin/bash |
....
 
X

xhoster

I am going to build a csv (or colon delimited, or space delimited, etc)
to ascii table converter...

Can you define an "ascii table"? To me, csv tables *are* ascii tables
already. well, unless they include nonascii characters.
does anything like this already exist?

e.g.:

./xsv2ascii -f /etc/passwd -d ":"
________________________________
| root | x | 0 | 0 | root | /root | /bin/bash |
...

So then, is an ascii table just a csv with all the separating commas turned
into " | ", with a "| " in front and a " |" behind?

Xho
 
C

Chris F.A. Johnson

I am going to build a csv (or colon delimited, or space delimited, etc)
to ascii table converter...


does anything like this already exist?


e.g.:


./xsv2ascii -f /etc/passwd -d ":"
________________________________
| root | x | 0 | 0 | root | /root | /bin/bash |
...

Do you mean something like this:

sep=:
rep=" | "
sed -e "s/$sep/$rep/g" -e 's/^/| /' -e 's/$/ |/'
 
B

bob the builder

./xsv2ascii -f /etc/passwd -d ":"
Do you mean something like this:

sep=:
rep=" | "
sed -e "s/$sep/$rep/g" -e 's/^/| /' -e 's/$/ |/'


well, actually more like this... and I know the text is going to be
trashed because of tabs / variable sized fonts, etc.

----------------.----------------.----------------.---------------
Host | IP Address | Management IP | iLO Address
----------------+----------------+----------------+---------------
gfd_ipcvxy | 168.178.52.28 | |
----------------+----------------+----------------+---------------
dfg_ipcvxya01 | 168.178.52.22 | | 146.171.67.29
----------------+----------------+----------------+---------------
ghk_ipcvxya02 | 168.178.52.24 | | 143.171.76.21
----------------+----------------+----------------+---------------

or this:

psql=# \d
List of relations
Schema | Name | Type | Owner
---------+----------------------------------+----------+---------
public | accounts | table | pgdba


or this:

http://www.stat.ucl.ac.be/ISpersonnel/lecoutre/stats/oips/xhtml/tableinASCII.jpg
 
B

bob the builder

B

Bart Lateur

bob said:
well, actually more like this... and I know the text is going to be
trashed because of tabs / variable sized fonts, etc.

----------------.----------------.----------------.---------------
Host | IP Address | Management IP | iLO Address
----------------+----------------+----------------+---------------
gfd_ipcvxy | 168.178.52.28 | |
----------------+----------------+----------------+---------------
dfg_ipcvxya01 | 168.178.52.22 | | 146.171.67.29
----------------+----------------+----------------+---------------
ghk_ipcvxya02 | 168.178.52.24 | | 143.171.76.21
----------------+----------------+----------------+---------------

Take a look at the module Text::Table,
<http://search.cpan.org/~anno/Text-Table-1.107/lib/Text/Table.pm>

That'll take care of the backend, converting the data into a fixed-pitch
font based, space padded, table.

You'll just need to read the data in first, the modules Text::CSV_XS, or
Text::xSV, could be helpful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,973
Members
47,529
Latest member
JaclynShum

Latest Threads

Top