Importing a CSV into Numbers does not work

I cannot for the life of me figure this out. I have a CSV file. When I highlight it and press spacebar to quick preview it, it looks perfect. When I open it in Numbers, it's a complete mess. Here is the source text:


"Client/Matter/Inv #", "Inv Date", "Fees", "Disb", "Total", "Tax", "Payments", "Balance"

"ACME Company, Inc.", "", "", "", "", "", "", ""

"Contract Preparation", "", "", "", "", "", "", ""

"ACI-7565", "8/1/17", "$2,595.00", "$47.53", "$2,642.53", "$0.00", "$0.00", "$2,642.53"

"ACI-7591", "9/19/17", "$1,964.00", "$0.00", "$1,964.00", "$0.00", "$0.00", "$1,964.00"

"ACI-7650", "9/6/18", "$900.00", "$0.00", "$900.00", "$0.00", "$0.00", "$900.00"

"MATTER TOTAL", "", "$5,459.00", "$47.53", "$5,506.53", "$0.00", "$0.00", "$5,506.53"

"CLIENT TOTAL ", "", "$5,459.00", "$47.53", "$5,506.53", "$0.00", "$0.00", "$5,506.53"

"", "", "", "", "", "", "", ""

"Greg Newcastle & Associates", "", "", "", "", "", "", ""

"Dissolution", "", "", "", "", "", "", ""

"GN-7420", "5/19/17", "$3,540.00", "$0.00", "$3,540.00", "$0.00", "$0.00", "$3,540.00"

"CLIENT TOTAL ", "", "$3,540.00", "$0.00", "$3,540.00", "$0.00", "$0.00", "$3,540.00"

"", "", "", "", "", "", "", ""

"Holt Construction Initiative", "", "", "", "", "", "", ""

"Non-Disclosure Agreement", "", "", "", "", "", "", ""

"HCI-7417", "5/19/17", "$795.00", "$0.00", "$795.00", "$0.00", "$0.00", "$795.00"

"CLIENT TOTAL ", "", "$795.00", "$0.00", "$795.00", "$0.00", "$0.00", "$795.00"

"", "", "", "", "", "", "", ""

"Janetta Marsh", "", "", "", "", "", "", ""

"Custody", "", "", "", "", "", "", ""

"JC-10", "7/1/16", "$1,525.00", "$0.00", "$1,525.00", "$0.00", "$500.00", "$2,245.00"

"CLIENT TOTAL ", "", "$1,525.00", "$0.00", "$1,525.00", "$0.00", "$500.00", "$2,245.00"



If you save this as a .CSV file, it previews perfectly in Finder, but is completely broken in Numbers. What am I doing wrong? I've been messing with this for WEEKS. So frustrating. Any help is much appreciated.

Posted on Jul 24, 2019 1:12 PM

Reply
Question marked as Top-ranking reply

Posted on Jul 24, 2019 3:09 PM

It is because of extraneous spaces. Instead of a comma as a delimiter, your file has a comma followed by a space. That space is interpreted as the first character of the next column, followed by the quotation mark, the text you want, and then the closing quatation mark. In TextEdit Find/Replace All "Comma Space" with "Comma" then inport the file.

14 replies
Question marked as Top-ranking reply

Jul 24, 2019 3:09 PM in response to pfjellman

It is because of extraneous spaces. Instead of a comma as a delimiter, your file has a comma followed by a space. That space is interpreted as the first character of the next column, followed by the quotation mark, the text you want, and then the closing quatation mark. In TextEdit Find/Replace All "Comma Space" with "Comma" then inport the file.

Jul 24, 2019 3:38 PM in response to pfjellman

 CSV is a standard format, and the C in CSV stands for comma


Actually CSV is only "sort of" a standard format. It comes in many different flavors. The "C" now stands for "character" in character separated format" and can be , or ; or | or various other characters, including tab. The semicolon ; is often an excellent choice if you have that option at the source.


But as you say, just replacing the , with ; won't work here as you have commas embedded within the Numbers.


The problem here, that confuses both Numbers and Excel, is that you have an extra space after each comma separator, ie. instead of "A","B","C","D","E","F","G" you have "A", "B", "C", "D", "E", "F" ,"G"


Simply remove that extra spaces (don't worry about removing commas or currency symbols and all that; just remove the extra spaces) and the data should import as expected. I removed the spaces by pasting into TextEdit and doing this search-replace:




I then pasted the result directly into a Numbers table.



SG

Jul 24, 2019 3:05 PM in response to Wayne Contello

Full post got cut off...


I copied the data you posted in this thread and pasted it into a new text file (shown here in VIM):


then I opened that file with Numbers and got this:





If you can, I suggest omitting the thousands separator (the comma in the numeric values). the double quotes do not properly assist Numbers in identifying fields.


If you can, use tabs as the field delimiter and omit the double quotes and commas.



Can you post your source and the result in Numbers?


Here is what I did to be able to import the file correctly:

1) Remove the double quotes by replacing '"' with nothing:


2) remove the currency symbol by replacing '$' with nothing:


3) replace the field delimiter (which is a comma followed by a space) with a tab:

4) remove all remaining commas (which should be the thousands separators):

5) Save text file, then open file with Numbers:


I just noticed I need to fix "Acme Company" and put the comma back i the text file:

"ACME Company Inc." should be "ACME Company, Inc."


save text file and open in Numbers


Jul 24, 2019 1:21 PM in response to AndreAcer

This cannot be right. CSV is a standard format, and the C in CSV stands for comma. I also cannot find and replace "," for ";" because all of the dollar values have "," in them if they are above 999. So this will not work, unfortunately.


I do appreciate your feedback though.


UPDATE: I tried this anyway, and it did not work. Even with ";" as the delimiter, the file is still not loading in Numbers properly.

Jul 24, 2019 4:00 PM in response to SGIII

I agree with @SGIII. Generally, if you are getting double-quotes alone in cells, it's either because the app importing (in this case Numbers) misinterprets CSV based on differing pattern exports, or because you are missing an errant comma or quote. @Wayne Cotello's extensive data-munging in most cases isn't necessary.


I don't like to use TextEdit for these tasks, though it will work in most circumstances. SubEthEdit and BBEdit are unlikely to try to "interpret" a text file; both have "show invisibles" which might lead you to a problem, and BBEdit has the command "Zap Gremlins" which eliminates non-alpha numeric characters which might also cause you problems.


But @SGIII has found the specific thing that is messing with your file. 'Nuff said

Jul 24, 2019 10:31 PM in response to pfjellman

"This cannot be right. CSV is a standard format, and the C in CSV stands for comma."


Well, sort of…


CSV, more accurately expanded as Character Separated Values, is a fairly 'loose standard. In North America, where the decimal separator is a period / full stop, the original "C" was, and for the most part, still is, a comma. Elsewhere in the world, where the decimal separator is a comma, the more common "C" is a semi colon, which doesn't conflict with either the decimal separator or the thousands separator.


Perhaps the simplest solution to this would be to open it with a more versatile spreadsheet application, such as LibreOffice.


Here is the result of copying the text from your post, pasting it into TextEdit, then with no editing of the pasted text, saving as a text file with the.csv extension, and opening that csv file directly into LibreOffice v5.1.4.2:


If you need the file to be in Numbers, that requires only these actions:

Select all the cells containing data in the LibreOffice table.

Copy,

In Numbers:

In an empty table, select (one click) the cell you want to contain Client.Matter/Inv #

Paste.


Regards,

Barry

Jul 25, 2019 4:52 AM in response to Barry

Recent versions of Numbers (unlike perhaps the older versions you may still be using) are excellent at importing character-separated values. Better even, in some cases, than Excel, which is also very capable at the task (with its Text to Columns function).


I don't have much experience with LibreOffice because, also, some of its modules are buggy and I also don't like the idea of having to install a compatible JRE (Java Runtime Engine) on my Mac.


For me it is easier (and perhaps more secure?) to simply use an included app (TextEdit is simple and powerful) and use that to perform a one-second find-replace operation if needed.


In general it's better (if possible) to address data format problems at the source. Often it's possible to tell the source to omit those extra spaces or to use another separator. Given a choice a ; is often an excellent option not just outside North America but also within North America as well. A tab is often an even better choice, as a tab is less likely to be embedded the text and also spreadsheets like Numbers and Excel directly accept pasted tab-delimited data.


In any case Numbers, in its current version, has become a truly excellent tool for this job. I find little need to download extraneous software or fire up Excel (as I used to do).


SG







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.

Importing a CSV into Numbers does not work

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