Skip to content

Instantly share code, notes, and snippets.

@jhanschoo
Last active February 1, 2022 22:24
Show Gist options
  • Save jhanschoo/bcd6d08d1e0f4b5d52735287f39ca924 to your computer and use it in GitHub Desktop.
Save jhanschoo/bcd6d08d1e0f4b5d52735287f39ca924 to your computer and use it in GitHub Desktop.
Uses LibreOffice to convert a file to csv format, preserving Unicode characters in UTF-8
#!/usr/bin/env sh
# localc2csv.sh [--outdir OUTPIT_DIR] FILE [FILE...]
# Uses LibreOffice to convert a file to csv format, preserving
# Unicode characters in UTF-8
# Assumes LibreOffice is installed to /Applications in MacOS.
# for documentation on the arguments, c.f.
# https://ask.libreoffice.org/en/question/2641/convert-to-command-line-parameter/
# https://help.libreoffice.org/Common/Starting_the_Software_With_Parameters
# https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options
## Unfortunately, LibreOffice documentation does not adequately cover
## convert-to parameters; know-how is scattered across forum threads.
/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to \
"csv:Text - txt - csv (StarCalc):44,34,76,1,1/1:" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment