6

I need to be able to save files created in LibreOffice Calc to CSV with the CRLF line endings.

I have tried many options but the files always come out missing the CR part.

I work with programs that will not import the CSV files without the windows line endings.

Adam
  • 341
  • 1
  • 10
  • 6
    Convert to CSV as you normally would, then use the unix2dos command on the files. – muru Dec 19 '16 at 07:54
  • There are no options related to line endings in the filter options, so it looks like the only way is to use an external tool. Of course, a custom macro could be written to do this, for example using Python open(). Or perhaps a custom XSLT export filter could do it. – Jim K Dec 19 '16 at 17:06
  • It is quite a while later; but this is still an issue. I usually just save the CSV file now and open and resave using gedit which allows choosing the line endings. – Adam Oct 29 '18 at 01:00

2 Answers2

2

Line termination is not part of the CSV specification. It depends on the operating system. If you work on linux you get LF; if you use windows, CRLF. When exporting any kind of text files from linux to windows a conversion tool is required: unix2dos.

  • 1
    I know; and it is a PITA. Gedit allows me to choose line endings....why not Libre Office. \ – Adam Mar 14 '19 at 20:17
1

I was automating a bunch of other stuff so I thought I would automate this also.

Using the Unix2dos command mentioned above; I now press F12 (open terminal in current folder) and type csv.

This is aliased to 'unix2dos *.csv' which is much faster then re-opening the files every time. I have tested that unix2dos doesn't do anything weird to the file if it is run more then once on the same file.

Notes: Getting F12 to open a terminal in the current folder. go to ~/.local/share/nautilus/scripts add a scripts called whatever (Terminal) in the script place

# !/bin/sh
gnome-terminal

Then go to ~/.config/nautilus/script-accels and add the shortcut you want; I set F12.

F12 <script name> (Terminal)
Adam
  • 341
  • 1
  • 10