Export to CSV format (Db2Csv)       

Db2Csv allows you to export all the data from one or all tables in a database
in CSV (comma separated value) format. Each column is separated by a comma;
if the column contains a comma it is enclosed in quotes.
Db2Csv writes the output by default to "table.csv" unless you
specify with the '-o' option a different output file.
Db2Csv also create the a header with all column names
unless you specify the "-n" option to write the CSV without the header line.
Db2Csv writes one line for each record.
If you dont specify a table with the "-t" option Db2Csv will export all tables.
Db2Csv writes all diagnostics to a log file "logs/yyyymmdd/db2csv.log"
The exported CSV data can be used in spreadsheets or imported into any
other databases with the DbLoad utility.
Note that In demo mode up to 100 records can be exported.

-usage: db2csv [-sn] [-d{db}] [-o{out}] [-t{tab}]
-d = DATABASE: Specify database input file (default Sample.mdb)
-o = OUTPUT  : Specify output filename (default Table.{xml|txt|csv|htm})
                 -o STDOUT writes directly to standard output not a file
-t = TABLE   : Specify Table name (default is all tables)
                 or table number ('#3' = 3rd table)
-s = SILENT  : Dont show diagnostics (XX Records written..)
-n = NOHEADER: Dont write DTD (XML), header line (TXT, CSV, HTML)

db2csv -d Sample.mdb -t Employees
9 'Employees' Record(s) written to 'Employees.csv'

Exports all data from the " Employees" table from database "Sample.mdb".
The output is written to "Employees.CSV".

Example CSV Output (Employees.csv)
Click here to open the Employees.CSV file

1,Davolio,Nancy,Sales Representative,Ms.,12/08/48,05/01/92,507 - 20th Ave. E.\r\nApt. 2A,Seattle,WA,98122,USA,(206) 555-9857,5467,Array of VT_UI1,Education includes a BA in psychology from Colorado State University in 1970. She also completed "The Art of the Cold Call." Nancy is a member of Toastmasters International.,2
2,Fuller,Andrew,"Vice President, Sales",Dr.,02/19/52,08/14/92,908 W. Capital Way,Tacoma,WA,98401,USA,(206) 555-9482,3457,Array of VT_UI1,"Andrew received his BTS commercial in 1974 and a Ph.D. in international marketing from the University of Dallas in 1981. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager in January 1992 and to vice president of sales in March 1993. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.",
3,Leverling,Janet,Sales Representative,Ms.,08/30/63,04/01/92,722 Moss Bay Blvd.,Kirkland,WA,98033,USA,(206) 555-3412,3355,Array of VT_UI1,Janet has a BS degree in chemistry from Boston College (1984). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate in 1991 and promoted to sales representative in February 1992.,2
4,Peacock,Margaret,Sales Representative,Mrs.,09/19/37,05/03/93,4110 Old Redmond Rd.,Redmond,WA,98052,USA,(206) 555-8122,5176,Array of VT_UI1,Margaret holds a BA in English literature from Concordia College (1958) and an MA from the American Institute of Culinary Arts (1966). She was assigned to the London office temporarily from July through November 1992.,2
5,Buchanan,Steven,Sales Manager,Mr.,03/04/55,10/17/93,14 Garrett Hill,London,,SW1 8JR,UK,(71) 555-4848,3453,Array of VT_UI1,"Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree in 1976. Upon joining the company as a sales representative in 1992, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London. He was promoted to sales manager in March 1993. Mr. Buchanan has completed the courses \"Successful Telemarketing\" and \"International Sales Management.\" He is fluent in French.",2
6,Suyama,Michael,Sales Representative,Mr.,07/02/63,10/17/93,Coventry House\r\nMiner Rd.,London,,EC2 7JR,UK,(71) 555-7773,428,Array of VT_UI1,"Michael is a graduate of Sussex University (MA, economics, 1983) and the University of California at Los Angeles (MBA, marketing, 1986). He has also taken the courses \"Multi-Cultural Selling\" and \"Time Management for the Sales Professional.\" He is fluent in Japanese and can read and write French, Portuguese, and Spanish.",5
7,King,Robert,Sales Representative,Mr.,05/29/60,01/02/94,Edgeham Hollow\r\nWinchester Way,London,,RG1 9SP,UK,(71) 555-5598,465,Array of VT_UI1,"Robert King served in the Peace Corps and traveled extensively before completing his degree in English at the University of Michigan in 1992, the year he joined the company. After completing a course entitled \"Selling in Europe,\" he was transferred to the London office in March 1993.",5
8,Callahan,Laura,Inside Sales Coordinator,Ms.,01/09/58,03/05/94,4726 - 11th Ave. N.E.,Seattle,WA,98105,USA,(206) 555-1189,2344,Array of VT_UI1,Laura received a BA in psychology from the University of Washington. She has also completed a course in business French. She reads and writes French.,2
9,Dodsworth,Anne,Sales Representative,Ms.,01/27/66,11/15/94,7 Houndstooth Rd.,London,,WG2 7LT,UK,(71) 555-4444,452,Array of VT_UI1,Anne has a BA degree in English from St. Lawrence College. She is fluent in French and German.,5

If you run this command on Feb 18th, 2001 the logfile would be created in:
INIT    |13:35:03.438 |====== Opening c:/dbtkxml/logs/20010218/db2csv.log ======
DbTkXml |13:35:03.549 |ExecCmd: opendb Sample.mdb
DbTkXml |13:35:03.599 |ExecCmd: table Employees
DbTkXml |13:35:03.619 |ExecCmd: CSVEXPORT Employees.csv
DbTkXml |13:35:03.639 |9 'Employees' Record(s) written to 'Employees.csv'

Table,Column,Field,Record,Index,Query,External Data,Save As,merge,synchronize,explorer,
command,line,batch scipts, shareware