[Solved] Number Re-formatting

Discuss the spreadsheet application
Post Reply
tad
Posts: 7
Joined: Wed Nov 28, 2007 6:21 pm

[Solved] Number Re-formatting

Post by tad »

Hello Everyone,

(I am using Version 3.1.1. Build 9420 from 9-15-2009.)

Opened a .csv file with Calc that was generated from my Paypal account.

Noticed that the column would not SUM. Scratched my head for a minute, then noticed that the numbers were formatted as text. The apostrophe was added to each cell in the column. (I have attached a screen shot for example purposes.)
import-apostrophe.png
import-apostrophe.png (13.47 KiB) Viewed 7832 times
import-number.png
import-number.png (18.95 KiB) Viewed 7832 times
As you can see, Calc sees Column B as being "numbers." It does not recognize the contents of Column C to be numbers.

Three concerns...

1. Why did Calc see these numbers as "text" when they were not text...

2. The column could not be reformatted as "numbers." Why?

3. I searched and searched for a way to remove the apostrophe so the contents of the cells in that column would once again become numbers. Could not figure out how to do so.

For the record, Excel 2007 handles this without a hitch.

Thanks very much for your help.
Tad
Last edited by tad on Wed Sep 30, 2009 2:51 am, edited 1 time in total.
billiam1185
Posts: 14
Joined: Mon Sep 28, 2009 4:19 pm

Re: Number Re-formatting

Post by billiam1185 »

Try opening your file with notepad, and using the replace function to replace all of the ' with nothing. Enter that character in the find box, and leave the replace box blank. Save the file, and see what happens!
OOo 3.0 Windows Vista
User avatar
aukejan
Volunteer
Posts: 147
Joined: Tue Jul 28, 2009 6:13 pm
Location: Netherlands

Re: Number Re-formatting

Post by aukejan »

Can you please upload one of your CSV files?
OOo 3.2.1 on Ubuntu Maverick
tad
Posts: 7
Joined: Wed Nov 28, 2007 6:21 pm

Re: Number Re-formatting

Post by tad »

billiam1185 wrote:Try opening your file with notepad, and using the replace function to replace all of the ' with nothing. Enter that character in the find box, and leave the replace box blank. Save the file, and see what happens!
Thanks very much for taking the time to help.
Tad
tad
Posts: 7
Joined: Wed Nov 28, 2007 6:21 pm

Re: Number Re-formatting

Post by tad »

aukejan wrote:Can you please upload one of your CSV files?
Would be happy to. I am being told, though, that I cannot post a file with the .csv extension. Hmmm. Any ideas?
Tad
User avatar
TheGurkha
Volunteer
Posts: 6482
Joined: Thu Mar 13, 2008 12:13 pm
Location: North Wales, UK.

Re: Number Re-formatting

Post by TheGurkha »

Zip it up. You can upload .zip files. If it is too big put it on something like MediaFire and post the link here.
Ubuntu 14.10 Utopic Unicorn, LibreOffice Version: 4.3.3.2
Gurkha Welfare Trust
tad
Posts: 7
Joined: Wed Nov 28, 2007 6:21 pm

Re: Number Re-formatting

Post by tad »

TheGurkha wrote:Zip it up. You can upload .zip files. If it is too big put it on something like MediaFire and post the link here.
Excellent. Here is the zip file that contains the file "test_file.csv". Thanks for the help.
Tad
Attachments
test_file.zip
(349 Bytes) Downloaded 185 times
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Number Re-formatting

Post by acknak »

tad wrote:... Three concerns...

1. Why did Calc see these numbers as "text" when they were not text...
Probably because they were quoted in the CSV file. A leading single quote is the only way I know of to get Calc to treat values in a CSV file as text.
2. The column could not be reformatted as "numbers." Why?
I assume you mean that changing the cell format didn't solve your problem--right? That's because changing the cell format never changes the type of the value that's stored in the cell. The format can only change the way the value is displayed. If your "SERIAL" values were read as text values, changing the cell format can not change them into numeric values.

Calc guesses a value's type when it is entered. To change the type, you have to enter the value again, and give some different clue as to what the type should be, like adding an apostrophe at the start.
3. I searched and searched for a way to remove the apostrophe so the contents of the cells in that column would once again become numbers. Could not figure out how to do so.
You can't remove it because it's not there. The apostrophe is just a clue that Calc should interpret the entry as text when normally it would interpret it as a number. When the value is stored, Calc sees the apostrophe, stores the value as text, then throws the apostrophe away. When you edit the value, Calc sees that the apostrophe is needed, and puts it back to save you from having to type it. When you finish editing, Calc throws it away again.

It's a confusing way to handle the problem, but it's not entirely Calc's fault: it's been this way since the dawn of spreadsheets.
For the record, Excel 2007 handles this without a hitch.
No doubt. Excel is quite good at doing things without bothering the user, but not infrequently the convenience ends up wrapped around the user's neck because Excel guessed wrong and the blissful user never knew there was an issue.

Do you really mean to add up a column of serial numbers?

You can change numeric text to numeric values using Edit > Find & Replace.

1) Select the cells (or the whole column)
2) Format the cells as some numeric format, or just as "Default" (Format > Default Formatting).
3) Edit > Find & Replace
Search for: .*
Replace with: &
Options: Regular expressions: YES; Current selection only: YES
Click "Replace all."

This has the effect of re-entering the values but without the apostrophe.

NOTE: It will also throw out any leading zeros that may be important for other purposes.

Alternatively, you can leave the numbers as text, and add them with a formula something like =SUMPRODUCT(VALUE(C2:C11))
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Number Re-formatting

Post by acknak »

PS: With OOo 3.1.1 and your sample file, I can't reproduce the problem as you described it. The SERIAL column comes in as numeric data for me.
AOO4/LO5 • Linux • Fedora 23
tad
Posts: 7
Joined: Wed Nov 28, 2007 6:21 pm

Re: Number Re-formatting

Post by tad »

"Do you really mean to add up a column of serial numbers?"
- - - -

This was a different file than the one I dealt with originally. It had the same behaviors as the other, though. I used the serial numbers column as an example.

Thanks VERY much for the excellent explanation.

Tad
coakley
Posts: 8
Joined: Tue Jan 19, 2010 3:47 am

Re: [Solved] Number Re-formatting

Post by coakley »

I have this same problem with OO 3.1.1 - please note that prior versions of Calc handled numbers just fine when importing or opening a txt/csv file. Something changed in 3.1.1.
OpenOffice 3.1.1 on Ubuntu Linux 9.10 or Mint Linux 8
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: [Solved] Number Re-formatting

Post by acknak »

Can you attach a few sample lines of your input? Without that, all anyone can do is guess what the problem might be.
AOO4/LO5 • Linux • Fedora 23
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Number Re-formatting

Post by Villeroy »

coakley wrote:I have this same problem with OO 3.1.1 - please note that prior versions of Calc handled numbers just fine when importing or opening a txt/csv file. Something changed in 3.1.1.
No, your problem is totally unrelated to this one and you should go back to your own topic instead of hi-jacking this one.
http://user.services.openoffice.org/en/ ... =9&t=26626
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
coakley
Posts: 8
Joined: Tue Jan 19, 2010 3:47 am

Re: [Solved] Number Re-formatting

Post by coakley »

I posted in this topic because one of the replies to my question led me here - quite on purpose. The issue here and my issue are certainly not the same, but they just as certainly could be caused by the same changes to the code. I thought it might be useful to point out that my problem did not exist in Calc until the 3.1.1 iteration and that perhaps that might be true of this issue as well.

Sorry to ruffle ...
OpenOffice 3.1.1 on Ubuntu Linux 9.10 or Mint Linux 8
User avatar
Scott M. Sanders
Posts: 35
Joined: Mon Dec 22, 2008 6:41 pm
Location: Ashland, Ohio, USA

Re: [Solved] Number Re-formatting

Post by Scott M. Sanders »

Is Calc ever gonna get this right? :?
LibO 3.5, OOo 3.4 beta 1, White Label 3.3; XP Pro SP3, Vista Home Premium SP2, 7 Pro SP1 64-bit; Ubuntu 11.10, Fedora 11 to 16, CentOS 6.2
mriosv
Volunteer
Posts: 651
Joined: Mon Mar 09, 2009 1:12 am
Location: Galiza (España)

Re: [Solved] Number Re-formatting

Post by mriosv »

The test file works fine for me in 3.1.1 an 3.2RC2
When you are in the import window:
Select tab separator.
In the header of the first column select M/D/Y (pick with right bottom)
In the header of the second column select US, if you don't use the dot as decimal point.
LibreOffice 3.5.4 AOo-3.4 on Win 7 Ultimate
Post Reply