port to convert comma delimited file

2003-03-25 Thread Dru

Hello,

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?

Dru
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: port to convert comma delimited file

2003-03-25 Thread Martin Karlsson
* Dru [EMAIL PROTECTED] [2003-03-25 20.51 -0500]:
 
 Hello,

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?

I couldn't find anything like that in the ports collection, but there
seems to be alternatives on the web, e.g. csv2html
URL:http://watson-wilson.ca/computer/csv2html.html.

Hint: search the web for csv (comma separated values) and html.

 Dru

HTH
-- 
Martin Karlsson
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: port to convert comma delimited file

2003-03-25 Thread Simon Barner
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 array
  
  for each component of the array (see the 'shift' function)
 print (TD);
 now print the element
 print (/TD);
 
  print (/TR);
  
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 is an
ideal motivation to get to now this mighty language.

Simon


signature.asc
Description: Digital signature
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: port to convert comma delimited file

2003-03-25 Thread Dru


On Wed, 26 Mar 2003, Martin Karlsson wrote:

 * Dru [EMAIL PROTECTED] [2003-03-25 20.51 -0500]:
 
  Hello,

 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?

 I couldn't find anything like that in the ports collection, but there
 seems to be alternatives on the web, e.g. csv2html
 URL:http://watson-wilson.ca/computer/csv2html.html.

 Hint: search the web for csv (comma separated values) and html.


Wow, that was quick. For the curious, the downloadable perl script does
the trick nicely :-)

Dru
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: port to convert comma delimited file

2003-03-25 Thread Giorgos Keramidas
On 2003-03-25 20:51, Dru [EMAIL PROTECTED] wrote:
 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?

Someone mentioned Perl.  Try the following little Perl snippet:

#!/usr/bin/perl

print TABLE\n;
while (defined($line = STDIN)) {
chomp $line;
print TRTD . join(/TDTD, split(/;/, $line)) .
/TD/TR\n;
}
print /TABLE\n;

Save this to a file called csv2html.pl and then run it like this:

$ perl csv2html.pl  filename.csv  filename.html

The power of Unix as an environment comes from the ability to write
small, throw-away programs like this one, in one of the dozens of
scripting languages that are usually available.  Why hunt for a port
to do something so simple[1] ?

[1] For some definintion of `simple'.

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: port to convert comma delimited file

2003-03-25 Thread Simon Barner
 Someone mentioned Perl.  Try the following little Perl snippet:
 
   #!/usr/bin/perl
 
   print TABLE\n;
   while (defined($line = STDIN)) {
   chomp $line;
   print TRTD . join(/TDTD, split(/;/, $line)) .
   /TD/TR\n;
   }
   print /TABLE\n;

Yes, this is exactly what I was thinking about :-)

Simon


signature.asc
Description: Digital signature
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]