Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data export to CSV: 'lines terminated by'

Status
Not open for further replies.

aniaD

Programmer
Aug 27, 2007
1
GB
Hi all,

I need a piece of code for my tcl/tk interpreter. I want to export data from my metakit tables to a CSV file and I need to specify a line terminator. I have a field delimiter specified, now i need to specify how the entire row is terminated. This will allow me smoot import of those CSV files to MySQL database. Does anyone know what the code for this may be?

Any ideas greatly appreciated.

Thanks,
aniaD
 
I assume you're using puts to write to the CSV file?
If so, you need to specify nonewline:
puts -nonewline $fid <data>
Then, you need to puts the terminator code (in hex). Let's say you want the terminator to be "B" (capital B):
puts -nonewline \x42

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top