Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've imported a CSV file having the first column to be date-time values in ISO 8601 format like

2012-01-01T00:00:00.000Z

for the first moment of the year 2012.

Then, willing to make LibreOffice to recognize the format (as I was looking forward to plot a diagram), I've selected the column, chosen Format Cells... and entered the custom time format as

YYYY-MM-DDTHH:MM:SS.000Z

And this seems to work if... I edit a cell to remove a hidden single-quote from its beginning (which serves to protect a cell content from being interpreted) as all the newly formatted cells now store values like

'2012-01-01T00:00:00.000Z

(note the single quote - it is only visible when you edit a particular cell).

And I am to do so for all the cells in the column. How can I automate this?

UPDATE: I've already found a solution for the particular case of mine: it helps to set a column format to "time" in the CSV import dialogue. But I am still curious how could this be done in case I wouldn't have the original .csv data file to import but only the .ods file with the data already imported without the format specified at the import time.

share|improve this question

3 Answers

up vote 7 down vote accepted

You can remove the leading single quote (which actually isn't part of the string in the cell) using a regex-based search and replace:

  • Search for all characters between the start and end of the string ^.*$
  • replace with match &
share|improve this answer
Thank heavens for the internet and for you, sir. This was exactly right. – queso Mar 5 '12 at 21:44
How the heck does it work if it even has no actual quote symbol (nor its code) in it? – Ivan Mar 26 '12 at 0:03

By the use of a little computer formatting and search magic trick (programing technique if you will) called a Regular Expression or regex for short. For examples please see - http://www.regular-expressions.info/examples.html

share|improve this answer
1  
you would be a cool dude if you could write an example regex. – Mikhail Nov 3 '12 at 11:47

Actually, you need a to quote the dollar sign first.

Basically libreOffice is prepending a single quote in the field, for some unknown reason. So, you need to replace anything up to the dollar sign with nothing. So, use the regex of ^.*\$ and replace it with nothing. Worked for me.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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