0

I have 3 strings: string1 string2 string3

I want to export file.csv

I try to use

echo "string1,string2,string3" >> file.csv

but its not working

Cuong Le
  • 3
  • 2
  • 2
    Why are you using shell code, if you want to write a Tcl program? Also, you need to clarify: Do you have literal strings, or Tcl variables holding those strings? – user1934428 May 31 '21 at 10:27

1 Answers1

0

File handling in Tcl takes a few more commands (but is more efficient when you're writing many lines as a result):

set f [open file.csv w]
puts $f "string1,string2,string3"
close $f

The w is critical: it says to open the file for writing.


If you're doing a lot of CSV writing, use the package in Tcllib for the job. It handles complicated edge cases for you.

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215