title: unotools - try to convert ods or excel files to csv using python
body: <p>What I need is a command line tool to convert excel and ods spreadsheet files to csv which I can use on a web server (Ubuntu 16.04).
  I already red this: <a href="https://pypi.python.org/pypi/unotools" rel="nofollow noreferrer">https://pypi.python.org/pypi/unotools</a>
  which works fine for the given examples.</p>
  
  <p>And this: <a href="http://www.linuxjournal.com/content/convert-spreadsheets-csv-files-python-and-pyuno-part-1v2" rel="nofollow noreferrer">http://www.linuxjournal.com/content/convert-spreadsheets-csv-files-python-and-pyuno-part-1v2</a>
  which should do the work I want it to do, but does not in my environment.</p>
  
  <p>My problem I think is in the method Calc.store_to_url:</p>
  
  <p><strong>Line throwing exception</strong></p>
  
  <p>component.store_to_url(url,'FilterName','Text - txt - csv (StarCalc)')</p>
  
  <p>I really would appreciate a hint.</p>
  
  <p><strong>Exception</strong></p>
  
  <p>unotools.unohelper.ErrorCodeIOException: SfxBaseModel::impl_store  failed: 0x81a</p>
  
  <p><strong>Full source</strong></p>
  
  <pre><code>import sys
  from os.path import basename, join as pathjoin, splitext
  
  from unotools import Socket, connect
  from unotools.component.calc import Calc
  from unotools.unohelper import convert_path_to_url
  from unotools import parse_argument
  
  
  
  def get_component(args, context):
      _, ext = splitext(args.file_)
      url = convert_path_to_url(args.file_)
      component = Calc(context, url)
      return component
  
  def convert_csv(args, context):
      component = get_component(args, context)
      url = 'out/result.csv'    
      component.store_to_url(url,'FilterName','Text - txt - csv (StarCalc)')
      component.close(True)
  
  
  args = parse_argument(sys.argv[1:])
  context = connect(Socket(args.host, args.port), option=args.option)
  
  convert_csv(args, context)
  </code></pre>