Given a raw csv file:

$ cat foo.csv 
foo, bar
buzz, "quoted string"

Libre office calc text import with separator and text delimiter set

If I open this one with Libre Office with these settings, I can view it nicely. Yet if I select the entire document again and copy it, the clipboard contains:

foo  bar
buzz    quoted string

I was expecting the clipboard to restore the raw csv again.

The example is very contrived, yet background is that I want to only export a sub fraction from a larger csv without having to cherry-pick via sed or using

head -n 1 > example.csv
cat large.csv | grep SOME_CODE >> example.csv // sometimes the filter is not as easy

I like to use LibreOffice Calc as it offers a nice filter feature through Data > Autofilter making it easy to find the lines I want to use. Yet extracting that selection is not as straightforward.

I will use the smaller file for setting up a unit test, which is why I don't want to change the format of the csv file even if it most likely wouldn't make much of a different given a proper csv parser.

As the point of the unit test is to make sure it parses the actual format properly, and I don't want to test against LibreOffice's understanding of a CSV file.

How can I maintain the raw formatting when copying from a CSV file in LibreOffice Calc?


2 Answers 2


Instead of Autofilter, use Data -> More Filters -> Standard Filter and copy results to Sheet2.

standard filter

Then from Sheet2, go to File -> Save As with type Text CSV to produce the following file.


This is slightly different formatting from the original. If it needs to be exactly the same, then LO Calc is not the right tool. Use sed or similar.


Paste it into a sheet,make sure it is all selected then go to Data > Text to Columns. This will open the same dialog that you see when importing a .csv file.

(I'm on Libreoffice btw)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.