Skip to content

Instantly share code, notes, and snippets.

@dv

dv/convert.rb Secret

Last active July 5, 2016 16:20
Show Gist options
  • Save dv/48bffc4877009a8c904ab61e4de7370b to your computer and use it in GitHub Desktop.
Save dv/48bffc4877009a8c904ab61e4de7370b to your computer and use it in GitHub Desktop.
# This runs:
escaped_out = "/var/folders/h3/286_8q714zzbrsyt55xjqyn00000gn/T/d20160705-68336-ib6zho"
escaped_doc = "/var/folders/h3/286_8q714zzbrsyt55xjqyn00000gn/T/small_analytic.xls20160705-68336-1fuvhtn.xls"
office_executable = '/Applications/LibreOffice.app/Contents/MacOS/soffice'
options = "--headless --invisible --norestore --nolockcheck --convert-to csv:\"Text - txt - csv (StarCalc)\" --outdir #{escaped_out} #{escaped_doc}"
cmd = "#{office_executable} #{options}"
result, error, pid = Open3.capture3(custom_env, cmd)
# This fails:
options = [
'--headless',
'--invisible',
'--norestore',
'--nolockcheck',
'--convert-to', 'csv:Text - txt - csv (StarCalc)',
'--outdir', escaped_out,
escaped_doc,
]
result, error, pid = Open3.capture3(custom_env, office_executable, *options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment