On 11-Aug-06 Alan Pope wrote:
On Fri, Aug 11, 2006 at 01:41:05PM +0100, Mark Rogers wrote:
I'm playing around with xls2csv (part of the catdoc application).
Something simple like: xls2csv -c~ products.xls > products.txt
does what I'd expect (exports the XLS, using "~" as the field separator).
Any suggestions how I can make this create a tab separated file instead?
I think this is more about how to pass the TAB through the shell (ie more to do with bash than xls2csv) but I could be wrong.
In some other tools I've used "\t" (sans quotes) to indicate a tab.
Dunno if that works in xls2csv though.
Cheers, Al.
Assuming from the description that after
xls2csv -c~ products.xls > products.txt
the only occurrences of "~" in products.txt is as a field separator, you should be able to straightforwardly us 'tr' to change it to "\t":
xls2csv -c~ products.xls | tr "~" "\t" > products.txt
E.g.
$ cat temp A~B~C~D~E~F~G A~B~C~D~E~F~G A~B~C~D~E~F~G A~B~C~D~E~F~G A~B~C~D~E~F~G A~B~C~D~E~F~G
$ cat temp | tr "~" "\t" > temp2 $ cat temp2 A B C D E F G A B C D E F G A B C D E F G A B C D E F G A B C D E F G A B C D E F G
$ od -c temp2 0000000 A \t B \t C \t D \t E \t F \t G \n A \t 0000020 B \t C \t D \t E \t F \t G \n A \t B \t 0000040 C \t D \t E \t F \t G \n A \t B \t C \t 0000060 D \t E \t F \t G \n A \t B \t C \t D \t 0000100 E \t F \t G \n A \t B \t C \t D \t E \t 0000120 F \t G \n
just as it should be!
Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@nessie.mcc.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 11-Aug-06 Time: 14:38:03 ------------------------------ XFMail ------------------------------