Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Mar 2003 03:09:39 +0100
From:      Simon Barner <barner@in.tum.de>
To:        Dru <dlavigne6@cogeco.ca>
Cc:        questions@freebsd.org
Subject:   Re: port to convert comma delimited file
Message-ID:  <20030326020939.GA657@zi025.glhnet.mhn.de>
In-Reply-To: <20030325204410.D17599@dhcp-17-14.kico2.on.cogeco.ca>
References:  <20030325204410.D17599@dhcp-17-14.kico2.on.cogeco.ca>

next in thread | previous in thread | raw e-mail | index | archive | help

--liOOAslEiF7prFVr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

> I have a comma delimited file with approximately 7000 rows and 5 columns.
> I have absolutely no database skills and and almost as much HTML skill,
> yet I need to convert this file into an HTML table. Is there something in
> the ports collection that will do this for me, a sort of converter for
> dummies? Barring that, is there any port that will do this, hopefully with
> docs so I can learn as I go?

You will not need the ports collection.

All you need is the perl programming language, and that's in the base system
(at least, if you are running 4.x, for 5.x you will have to install a port
indeed).

Have a look at the 'split' function.
Your perl script will perform the following algorithm:

print ("<TABLE>");
Read the input file line-wise
   for each line, do the following
      print ("<TR>");
      split the line (with comma as separator) and put the result into an a=
rray
	 =20
	  for each component of the array (see the 'shift' function)
	     print ("<TD>");
		 now print the element
		 print ("</TD>");
		=20
	  print ("</TR>");
	 =20
print ("</TABLE>");

There are lots of perl tutorials around the 'net, but if you perfer books, =
I'd
recommend "Lerning Perl" (Oreily), which I found very helpful.

Btw.: Some perl knowledge can never harm in a UN*X environment. Your task i=
s an
ideal motivation to get to now this mighty language.

Simon

--liOOAslEiF7prFVr
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQE+gQvjCkn+/eutqCoRAiXyAJ4/mfN+yRixdN6KRtp/DCBajQyt7ACgkP8g
U2h68YPaNQtfxOTImXV/l/s=
=0Fig
-----END PGP SIGNATURE-----

--liOOAslEiF7prFVr--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030326020939.GA657>