@@ -81,6 +81,7 @@ def __init__(self):
8181
8282 # defaults for export
8383 self .default_header = True
84+ self .default_separator = ","
8485
8586 def create_menu (self ):
8687 """create the menu of the application"""
@@ -686,7 +687,7 @@ def bip(c):
686687 log .write ("\n " )
687688 instru = next (self .conn .get_sqlsplit (instruction ,
688689 remove_comments = True ))
689- instru = instru .replace (";" , "" ).strip (' \t \n \r ' )
690+ instru = instru .replace (";" , "; " ).strip (' \t \n \r ' )
690691 first_line = (instru + "\n " ).splitlines ()[0 ]
691692 if instru [:5 ] == "pydef" :
692693 pydef = self .conn .createpydef (instru )
@@ -706,6 +707,8 @@ def bip(c):
706707 self .default_header = False
707708 elif shell_list [1 ].lower () == 'on' :
708709 self .default_header = True
710+ if shell_list [0 ] == '.separator' and len (shell_list ) >= 2 :
711+ self .default_separator = shell_list [1 ]
709712 if shell_list [0 ] == '.import' and len (shell_list ) >= 2 :
710713 csv_file = shell_list [1 ]
711714 if (csv_file + "z" )[0 ] == "~" :
@@ -757,6 +760,7 @@ def bip(c):
757760 csv_file = os .path .join (self .home , csv_file [1 :])
758761 self .conn .export_writer (instruction , csv_file ,
759762 header = self .default_header ,
763+ delimiter = self .default_separator ,
760764 encoding = encode_in )
761765 self .n .add_treeview (tab_tk_id , ('qry' , 'file' ),
762766 ((instruction , csv_file ),),
@@ -1634,11 +1638,13 @@ def _main():
16341638SELECT ItemNo, Description FROM Item; -- see all is back to normal
16351639RELEASE SAVEPOINT remember_Neo; -- free memory
16361640\n \n -- '.' commands understood:
1637- -- .headers on|off Include column headers in next .once exports (default on)
1638- -- .once [--bom] FILENAME Output of next SQL command to FILENAME [with utf-8 bom]
1641+ -- .headers on|off Include column headers in next .once exports (default on)
1642+ -- .separator COL Set column separator in next .once exports (default ,)
1643+ -- .once [--bom] FILE Output of next SQL command to FILE [with utf-8 bom]
16391644-- .import FILE TABLE Import data from FILE into TABLE
16401645-- (create table only if it doesn't exist, keep existing records)
16411646.headers on
1647+ .separator ;
16421648.once --bom '~this_file_of_result.txt'
16431649select ItemNo, Description from item order by ItemNo desc;
16441650.import '~this_file_of_result.txt' in_this_table
0 commit comments