Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

how to import csv-file in Numbers 3.2.2.

I start using Numbers in stead of Excel. I would like to import csv-files from my bank, but when I open the csv-file in Numbers, everything is imported in the same cell. I composed a testfile: 01/08/2014,”text”,”more text”,”even more text” in Pages, exported to a textfile and changed the extension from .txt in .csv. It did not help, everything was in the same cell. What must be changed to become successful in importing csv-files? I am using Numbers 3.2.2. and an iMac with 2,8 GHz Intel Core i7 processor and 8 GB 1067 MHz DDR3 memory with OS X 10.9.4.

Thanks, Joan Voormolen

iMac, OS X Mavericks (10.9.4)

Posted on Sep 1, 2014 7:26 AM

Reply
Question marked as Best reply

Posted on Sep 1, 2014 10:58 AM

In order to import comma-separated CSV into Numbers.app properly, you need to set the decimal separator to period in System Preferences. If decimal separator is set to comma, Numbers.app can only import semicolon-separated CSV.


What you need to do would be -


1) Quit Numbers.app;

2) Set the decimal separator to period, temporarily, in System Preferences;

3) Launch Numbers.app, import the CSV file and save the resultant Numbers file;

4) Quit Numbers.app;

5) Reset the decimal separator to the original (presumably, comma) in System Preferences;



Forcing user to change system's number format temporarily just in order to import a CSV file of some sort has been a long standing design flaw of this application, which has never been corrected.


H

30 replies
Question marked as Best reply

Sep 1, 2014 10:58 AM in response to JOANV

In order to import comma-separated CSV into Numbers.app properly, you need to set the decimal separator to period in System Preferences. If decimal separator is set to comma, Numbers.app can only import semicolon-separated CSV.


What you need to do would be -


1) Quit Numbers.app;

2) Set the decimal separator to period, temporarily, in System Preferences;

3) Launch Numbers.app, import the CSV file and save the resultant Numbers file;

4) Quit Numbers.app;

5) Reset the decimal separator to the original (presumably, comma) in System Preferences;



Forcing user to change system's number format temporarily just in order to import a CSV file of some sort has been a long standing design flaw of this application, which has never been corrected.


H

Sep 1, 2014 4:12 PM in response to JOANV

Rather than changing System Preferences you may find this CSV to Tabs on Clipboard Automator Service (Dropbox download) convenient to use.


Doubleclick to install in the Finder Services menu (you may have to confirm your intention by clicking 'Open Anyway' in System Preferences > Security & Privacy).


Thereafter, to use just:


  1. In Finder right-click the csv file.
  2. Choose 'CSV to Tabs on Clipboard' under Services in the contextual menu.
  3. Answer the prompts about the separator character.
  4. Click once in a Numbers cell in an existing table and command-v to paste.


SG

Oct 28, 2014 11:01 AM in response to SGIII

You can do this using Pages. Without using outside scripts or functions. The Pages Find/Replace function will let you change the delimiter on the data in your file.


Open the file in Pages. Click Show Invisibles. (this will show you the delimiter used in the file)

  • If you see a * as the delimiter, that is a space. Some data files are space delimited. This is a really poor way to delimit numerical data files.
  • If you see a fat arrow to the right, the file is Tab delimited
  • Obviously, a comma is not a hidden character. Some files are comma delimited
  • Whatever else might have been used as a delimiter (for example a semi colon is sometimes used) will be apparent.

The delimiter should be something that is not used anywhere else in the "data"... text, numbers, etc., you want to delimit. Numbers considers a comma as a valid delimiter for files with the suffix .csv . It considers a tab as a valid delimiter with files with the suffix .txt . It does not consider spaces a valid delimiter in with any file suffix. But some programs use odd delimiters (semi colon, colon, double spaces, etc) as delimiters.


Use the Find command, then Find/Replace as you need to create that delimiter numbers recognizes. Let's say a semi colon was used as a delimiter. Enter the current delimiter (semi colon) into the Find box. Pages should highlight all the instances of your entry. Enter a comma (to create comma delimited data file) in the Replace box. You should now see a comma as the delimiter.

Important Don't forget, any other comma used in the file will also be considered a delimiter. (a comma in 1,000 for example). So check the data. If you see a comma used another way you will want to eliminate that BEFORE you do the "comma as delimiter" replacement. If you have 1,000, do a find/replace with comma as the find, nothing as the replace, first. THEN do the replacement of the semi colon.


Now comes the "tricky" part from what I could see. You want to save this new file with a suffix of .csv. (Export the file) Numbers will only open a comma delimited file with separated data (by comma) if it's suffix is .csv. Pages only gives you limited export options and puts the file suffix on for you automatically. CSV is not one of the options!


Choose Text. Pages will name the file .txt. Quit Pages. Go to the file on your desktop (or wherever you saved it). Change the file suffiix from .txt to .csv.


That's it. Open the file with Numbers. Numbers will create a separate column for everything between the comma's.


You can use this same method to alter your data file before you import it into Numbers. For example, one file I wanted to import had time=xxx . I only wanted the actual time, not the text attached to it, in my spreadsheet. I did a find/replace with "time=" as the find. A comma as the replace. Even though "time=xxx" is one "word", Pages identified the "time=" within the word to allow the replacement.


Numbers does not provide a "choose delimiter" function when opening a file. Instead it automatically uses the standard delimiter based on the file suffix. CSV means Comma, so if the file is named .csv it will only look for and use a comma as the delimiter to put the data into separate columns. I believe .txt uses only a tab as the delimiter. In the above example you could find/replace to a Tab. Then Export to Text. And numbers will open the data into columns the way you want, without the extra step of renaming the file on your desktop.


While some files use a second space (ie two in a row) as a delimiter that's a nasty way to delimit. You always want a specific delimiter that is not used within the data element.


The above is to import numerical data into separate columns. You could use the same method to manipulate a file that contains text. Let's say you had a file with the suffix .txt. In the file are names and addresses. John Smith 246 Rose Road . You want Name in one column. Address in another. Look at all the spaces, which ones should be delimiters which not? Are there any delimiters in the file?


If you open with Pages and choose show invisibles you can see. You might see John Smith --> 246 Rose Road. (the --> will look like a fat arrow in Pages). Numbers will open this file, IF it has .txt as the suffix, based on the Tab, with name in one column, Address in another.


Or you might see John*Smith**246*Rose*Road. Even though the creator of this intended two spaces to be a delimiter Numbers does not recognize that. Numbers will put everything into one column. The fix? In Pages, put a tab between name and address. Find/replace two spaces with Tab. Export, as Text.


Based on what you see (with show invisible active) in Pages, you can use the Find/Replace function to create the specific delimiter you want (tab or comma). You can use that function to manipulate the file easily so the data you want shows up in separate columns. You may need to get clever to accomplish the unique delimiters. You might even need to do two passes with Find/Replace.


In the instance above if there was only one space between each element. (not two as a pseudo delimiter) You could replace all spaces with a tab in Pages. Export as Text. Numbers will open that file with a column for each word (one for John, one for Smith). Then "Merge" the two cells (columns) you want to put back together.

Oct 28, 2014 12:11 PM in response to wolfbyte

Thanks for posting this. However, I think in most situations my Automator Service will be a *lot* quicker and easier to use than messing around manually in Pages. It's based on some pretty nifty scripting by Nigel Garvey and others. It handles most situations nicely without the user having to worry too much about the details.


SG

Oct 28, 2014 4:16 PM in response to SGIII

I tried installing this. I dont see the option to use it in the Services menu when right clicking on a CSV file I created by saving an excel file, in excel, to csv. Just to be sure I installed a second time and the installer said it already existed. I am running OS 10.1. I see a lot of other "Services" options, which I never looked at so it was worthwhile already just to have seen what's there.


The question I was going to ask (but thought I should try it first) was how you answer delimiter questions if you dont open the file. Obviously, if it's csv it should be comma delimited. Should this only show up if the file suffix is csv or is it also available with other file suffixes (like txt).


Hopefully I dont need to run a virus scan (grin). I'm sure I dont . BTW I'm curious how do you uninstall things that are in the Services menu?


I can envision how this would work very easily compared to what I described. Using Pages, however, seems to let you work with more options than just a csv. So while this Automator seems very attractive for the specific instance, understanding what is going on, (using Pages) might be useful in other instances. It's obviously longer to do with Pages.

Oct 28, 2014 5:18 PM in response to wolfbyte

Hi Wolfbyte,


The script in the service is currently configured recognize csv, txt, and tsv suffixes. Note that csv stands for "character-separated-values". The character could be a comma, a semicolon, a tab, a pipe character or something else. The scripts prompts you to tell it what you think the separator is.


In Finder (not in Excel, Numbers, etc.) select a file with one of these suffixes, then in the Finder > Services menu choose "CSV to Tabs on Clipboard" and follow the prompts about separator. When it notifies that it's done, in Numbers click once in a cell in an existing table and command-v to paste. In most situations this is quick and easy, taking a few seconds.


To remove this or any other service, in Finder just hold down the option key and Go > Library and navigate to the Services folder. Locate the workflow package you want to delete and send it to the trash the way you would any other item in Finder.


You can see what the AppleScript looks like by opening the .workflow package in Automator (you should have seen that option when you double-clicked it).


SG

Oct 29, 2014 12:44 AM in response to SGIII

Yep I did all those things and it wasn't there However, NOW it's there! No idea why, I didnt miss it, and I haven't restarted my computer. Very cool. Nice script! You're right more people should look at this and try it out.


I do not understand why Apple did not include this functionality in Numbers. They could have maintained their current set up, and simply added a menu item that provided for any other options.


I've also been playing with Numbers, trying to migrate away from Excel. I find other, either missing functions or they are really obscure. I've been using Apples since the very first Mac (the really first one with the signatures inside the case, which I wish I still had lol) and have always appreciated Apple's approach to the UI. Been not just a supporter, but implementer of Apple products even back when "IBM" was the only way to go in business. I remember giving Guy Kawsaki (sp?) grief for my being shipped Macs with no spreadsheet software ... Excel was still in Beta. lol


But in this instance (Numbers, and to some degree Pages) not so much.

Dec 29, 2014 2:06 PM in response to NxtLeap

Hi NxtLeap,


It can't be both comma separated as well as have commas in the text, that is impossible! As no CSV reader could understand when to split.


Excel and many other applications with CSV (character separated value) parsers can indeed handle this situation. It is not "impossible" at all. It is in fact very common.


In case there are commas in the text, there has to be some other way it has differentiated commas (between fields) and commas (in fields)


Yes, there is a common way to differentiate. The fields containing commas are typically surrounded by quotation marks.


But there might be both quotation marks and commas within a field!


So as you can see it is not nearly as straightforward as making a simple find-replace in a text editor. A good parser can handle the different situations pretty well, as well as situations where the separator is not a comma, but a semi-colon or other character.


Excel is really good at this. With Numbers I've have the best luck with this CSV to Tabs on Clipboard Automator Service. It contains a parser handler (AppleScript term for subroutine) adapted from a posting by Nigel Garvey on MacScripter. To install it on your Mac, double-click the .workflow package and if necessary click 'Open Anyway' in System Preferences > Security and Privacy. To use it, in Finder right-click the file containing the character-separated data, choose the service from the contextual menu, then in Numbers click a cell in a table once, and command-v to paste. I think you will find it is much quicker and easier to use, and will give better results, than fiddling with TextEdit and such.


SG

Dec 30, 2014 4:06 AM in response to NxtLeap

Hello


You might read the following thread, where I explained why I advise user to use designed method rather than potentially problematic script and yet even provided a version of my script which I tried to make safer but is still potentially problematic due to the limitation of TSV representation.



Why won't Numbers 09 open when a tab delimited file is placed over the Numbers icon in Applications

https://discussions.apple.com/thread/5948764



Regards,

H

how to import csv-file in Numbers 3.2.2.

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