When I try a script to import CSVs into MonetDB databases as suggested by its author, it runs fine on my mac (Python 2.7.6 from the Anaconda distro) but it raises an error: too few arguments
on Windows 2012 Server (Python 2.7.5 from Anaconda).
I think all flags but --database
should be optional, plus you need to specify a filename — this is exactly working on my mac, not on Windows.
What is the way to bugfix this? Is this a known issue with argparse
for Windows?
Or if I should escape \
characters in the filename, why doesn't Python complain about the file not existing, why about too few arguments? (And in any case, as I specify the files in a Windows batch file, I cannot escape \
there easily.)
I repeat the argument parsing part of the script for convenience:
parser = argparse.ArgumentParser(description='A "smarter" CSV loader for MonetDB, v.0.3, hannes@cwi.nl, 2014-05')
parser.add_argument('--database', help='Database name to connect to', default='')
parser.add_argument('--port', help='MonetDB TCP port, defaults to 50000', default='50000')
parser.add_argument('--user', help='MonetDB username, defaults to "monetdb"', default='monetdb')
parser.add_argument('--password', help='MonetDB password, defaults to "monetdb"', default='monetdb')
parser.add_argument('--header',action='store_true', help='set if given CSV file has a header in the first line')
parser.add_argument('--yes',action='store_true', help='if set, assume Yes on all questions')
parser.add_argument('files', nargs='+', help='One or many CSV files to be imported')
args = parser.parse_args()