Stop Numbers form auto-formatting imported data

I use a program to track my time, and it exports as a tab-delimited text file. This should be perfect, just import the data into a Numbers table and bada-bing, right?

Unfortunately, Numbers is taking it upon itself to auto-format the data as it comes in. For example, there are 2 columns in the report that get auto-formatted. The event start column is exported in the form: dd/mm/yyyy hh:mm, and this is handled fine. The duration column is exported in the form: hh:mm, yet is auto formatted as dd/mm/yyyy hh:mm by Numbers.

Does anyone know a way to stop Numbers from doing this? My only quick workaround is to import the report in Excel first, then open the Excel xsls file in Numbers (and at that point, why bother using Numbers at all?).

HELP!

MacBook 2.2GHz, iPod Touch 1G, Mac OS X (10.5.6)

Posted on May 13, 2009 5:01 AM

Reply
11 replies

May 13, 2009 8:08 AM in response to KOENIG Yvan

That's not going to help, because the "duration" column is being auto-formatted by Numbers as a date and time. So, even if the target column is preformatted as a duration, it's getting the wrong data.

Essentially, Numbers is getting it wrong. Apparently, there is no solution (short of Apple recoding Numbers to not be quite so agressive when auto-formatting data). As I said, the "duration" column appears in the text file as "1:00" for a 1-hour task, and "0:30" for a half-hour task, etc. Numbers is erroneously shoehorning that data into a "date/time" format.

I guess I'll keep trying to figure out the best workaround, as I really don't want to use Excel.

May 13, 2009 6:54 AM in response to Jerrold Green1

Jerrold,

The problem with that is that when I do select the table and change the format to text, it remains as dd/mm/yyyy hh:mm (to clarify, when it is first imported, it just appears as hh:mm am/pm, eg., 1:00AM). This is something Numbers is doing when it first imports the text file, as opening the file in TextEdit shows it is being saved by the time tracking program as hh:mm (eg., 1:00).

Any other ideas?

May 13, 2009 7:35 AM in response to Leland Jory

What you got is due to the fact that when Numbers imports the TSV document, it doesn't know your wishes and it apply its automatic formatting which we can't disable.

Here is my own tip:

Open your TAB delimited file in Pages

Select All
Copy
Paste in a pre formatted Numbers document.

This time the values which where hh:mm will remain hh:mm if they are pasted in a column formatted this way.

Yvan KOENIG (from FRANCE mercredi 13 mai 2009 16:35:28)

May 13, 2009 10:24 AM in response to Leland Jory

NO. May you read carefully the given responses ?

I repeat,
if you _use copy-paste as I described,_ the preset formatting is kept.

I tested before posting.

When I copy 0:30 from a Pages document and paste it in a cell formatted as date_time with date set to none, I get the time only as required.
User uploaded file

Numbers does exactly what it is designed to do.
When it imports, it apply the automatic formatting
When it receive pasted datas it apply the pre-defined format.

It's your duty to use it the way which fit your needs.

Yvan KOENIG (from FRANCE mercredi 13 mai 2009 19:23:35)

May 13, 2009 1:32 PM in response to KOENIG Yvan

YES, I have read carefully the given responses. Here's the thing. The program I use exports to a tab-delimited text file. Opening the file in TextEdit gives me something like the following:

May12 12/05/09 8:30 AM 1:00 0. 7 TaskName

The third column (in the above example) is the duration column in hours and minutes. When I import this text file into Numbers, it automatically converts "1:00" to 1:00AM on the day following the task (so in the above example, it would autoconvert it to "13/05/09 1:00 AM"). I never get the chance to copy and paste the values into preformatted cells, as the data gets mangled *on import*.

However, I have found a workaround (thanks to my friend Adam, props!). TextEdit will do column text selection by holding down the option key and dragging through the column. So, I can copy the duration text and paste it into the preformatted fields in my timesheet template.

Thanks to everyone who helped.

Message was edited by: Leland Jory

Message was edited by: Leland Jory

EDIT: Oops, maybe I didn't read the reply quite closely enough. I missed the part about using Pages. Not sure if it does column select with the option key, but if so then that would probably work. The nice thing about using TextEdit is it is waaaaay quicker than using Pages.

May 13, 2009 3:18 PM in response to Leland Jory

Leyland,

I'm glad that you have found a satisfactory method, but in my opinion, you're making the process much more difficult than it needs to be. If you simply Copy the Tab-delimited text to the clip board and paste into a Numbers Table, pre-formatted correctly, you're done. You select A1 in your properly formatted Table and Paste. That's it. Your Duration format needs to be "0h 0m", available in the Inspector.

Jerry

May 13, 2009 3:22 PM in response to Jerrold Green1

Actually, your suggestion won't work in my situation for a few reasons. Chiefly, the data is not exported in the same order/layout/format as it has to end up in. I'm copying/pasting the data into a premade template where the columns aren't in the same order. Secondly, in order to copy/paste the data, I have to open the exported text file in something, which is where the data was getting mangled by Numbers.

I could have used the other suggestion (had I been paying close enough attention) of opening the exported text in Pages first, then copying the data into Numbers. I find TextEdit does the same thing, and slightly faster. If I have to use 2 apps, one might as well be as "light" as I can get.

As before, however, I appreciate all of the suggestions.

May 13, 2009 5:22 PM in response to Leland Jory

If this is an option for you, the Date & Time can be returned to a duration with a formula after import.

1. Select the column that contains the 1:00 AM. Then in the Cells Inspector, set Date to None. This will change the format from Automatic to Date & Time. We do this to ensure the value displayed will not change later.

2. If 1:00 AM is in cell A1, then =DURATION(,,LEFT(A1,SEARCH(":",A1)-1),MID(A1,SEARCH(":",A1)+1,2))

3. You can then format the duration to any format you like (e.g. 1:00 or 1 hour 0 minutes, etc...). And you can now add it to a date if that is the goal.



For the record, it appears to me that both Excel and Numbers import the hh:mm as a Date & Time. Excel doesn't choke on this because in Excel, dates are also numbers.

Robin

Message was edited by: sharknca

May 14, 2009 5:01 AM in response to Leland Jory

No need to use two applications!

--[SCRIPT dateTime2duration.app]

(*
Enregistrer le script en tant que Script, Application ou Progiciel : dateTime2duration.xxx
déplacer l'application créée dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.

Sélectionner les cellules à convertir

menu Scripts > Numbers > dateTime2duration

Le script insère les durées correspondantes.

--=====

L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".

+++++++

Save the script as a Script, an Application or an Application Bundle: dateTime2duration.xxx

Move the newly created application into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.

Select cells to convert.

menu Scripts > Numbers > dateTime2durationNumbers

The script insert the corresponding durations.

--=====

The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.

--=====

Yvan KOENIG (Vallauris FRANCE)
14 mai 2009
*)
--=====
on run
set {dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
set localOffset to (time to GMT)
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
repeat with x from colNum1 to colNum2
tell column x
repeat with y from rowNum1 to rowNum2
try
set theDate to (value of cell y)
if class of theDate is date then
tell (theDate - localOffset)
set {hh, mm, ss} to {(its hours) as text, its minutes, its seconds}
end tell
set value of cell y to hh & "h" & mm & "m" & ss & "s"
end if -- class…
end try
end repeat -- y
end tell -- column x
end repeat -- x
end tell -- Numbers …
end run
--=====
on getSelParams()
local r_Name, t_Name, s_Name, d_Name, col_Num1, row_Num1, col_Num2, row_Num2
set {d_Name, s_Name, t_Name, r_Name} to my getSelection()

if r_Name is missing value then
if my parleAnglais() then
error "No selected cells"
else
error "Il n'y a pas de cellule sélectionnée !"
end if
end if

set two_Names to my decoupe(r_Name, ":")
set {row_Num1, col_Num1} to my decipher(item 1 of two_Names, d_Name, s_Name, t_Name)
if item 2 of two_Names = item 1 of two_Names then
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
else
set {row_Num2, col_Num2} to my decipher(item 2 of two_Names, d_Name, s_Name, t_Name)
end if
return {d_Name, s_Name, t_Name, r_Name, row_Num1, col_Num1, row_Num2, col_Num2}
end getSelParams
--=====
on decipher(n, d, s, t)
tell application "Numbers" to tell document d to tell sheet s to tell table t to return {address of row of cell n, address of column of cell n}
end decipher
--=====
(*
set { d_Name, s_Name, t_Name, r_Name} to my getSelection()
*)
on getSelection()
local _, theRange, theTable, theSheet, theDoc, errMsg, errNum

tell application "Numbers" to tell document 1
repeat with i from 1 to the count of sheets
tell sheet i
set x to the count of tables
if x > 0 then
repeat with y from 1 to x
try
(selection range of table y) as text
on error errMsg number errNum
set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
return {theDoc, theSheet, theTable, theRange}
end try
end repeat -- y
end if -- x>0
end tell -- sheet
end repeat -- i
end tell -- document
return {missing value, missing value, missing value, missing value}
end getSelection
--=====
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
--[/SCRIPT]


Yvan KOENIG (from FRANCE jeudi 14 mai 2009 14:01:29)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Stop Numbers form auto-formatting imported data

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.