The convention, as I understand it, for handling embedded commas in of
csv data is to wrap each datum in double quotes. This cheerfully
introduces the problem of embedded double quotes in of csv data, of
course, and the conventional solution is to substitute two adjacent
double quotes for each double quote. Very easy to generate, but it makes
writing csv parsing routines deplorable. Your parser has to have
1-character of read-ahead to distinguish an embedded double quote from
the end of the cell.

TAB-delimited files do avoid this situation, but bank on your not having
tabs in your data. I am not aware of any conventional method for dealing
with tab-embedded tab-delimited data.

Almost makes XML seem like a good idea.

Mike Doyle
Unix Developer / Administrator
AMO Recoveries

On Fri, 2006-01-13 at 14:01 -0800, Kent Walker wrote:
> George,
> 
> Mike is right - a Perl script can make the conversion easy and highly 
> automated.  However, I like to use TAB-delimited output to avoid the 
> occasional messy situation when valid data contains commas or 
> quotes.  Write the program or paragraph such that it generates a text 
> file and then shells to the Perl program to do the conversion.
> 
> ActiveState's Perl for Windows does have the 
> "Spreadsheet::WriteExcel" and "Text::CSV" modules available.
> 
> Let me know if you want some samples to hack.
> 
> Kent
> 
> At 01:02 PM 1/13/2006, Michael Doyle wrote:
> 
> >On UNIX, use Perl. Specifically, use the Spreadsheet::WriteExcel and
> >Text::CSV modules. My csv2xls.pl script is only about 47 lines long.
> >
> >The Spreadsheet::WriteExcel module was utter garbage a few years ago,
> >but thanks to the efforts of OpenOffice.org and the obvious benefits of
> >open source software, the module has improved by leaps and bounds.
> >
> >On Windows, I can only presume that Visual Basic can generate Excel
> >spreadsheets.
> >
> >Mike Doyle
> >Unix Developer / Administrator
> >AMO Recoveries
> >
> >
> >On Fri, 2006-01-13 at 14:45 -0500, George Gallen wrote:
> > > Our UV system creates an ASCII .csv file for another
> > >   system to import on a daily basis. The 3rd party software
> > >   after a recent upgrade now only imports .xls files.
> > >
> > > Is there an easy way to "automate" Excel to load the .csv,
> > >   then save as .xls?
> > >
> > > Or how much more difficult is it to create the .xls instead of
> > >    a .csv?
> > >
> > > I thought about getting one of those programs that records
> > > mouse clicks, and create a macro of the conversion (since the
> > > filename is the same each day), but wonder if there was
> > > something we could do in a batch file and run every day under
> > > the Windows scheduler.
> > >
> > > George
> > >
> > > George Gallen
> > > Senior Programmer/Analyst
> > > Accounting/Data Division
> > > [EMAIL PROTECTED]
> > > ph:856.848.1000 Ext 220
> > >
> > > SLACK Incorporated - Delivering the best in health care information and
> > > education worldwide.
> > > http://www.slackinc.com
> > > -------
> 
> ---
> Kent Walker - Datatel Analyst
> Information Technology - U.C. Hastings College of the Law
> 415-565-4635
> -------
> u2-users mailing list
> [email protected]
> To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to