Leading Zeros

I have researched the threads about the subject of importing a .csv file and trying to keep the leading zeros once in Numbers and am completely unsatisfied with the results. I called Apple Care today and God Bless them but they really had nothing to offer me as far as helping me with this issue. I have a large Data sheet with random leading zero numbers throughout. (starting with anywhere from 1 to 6 zeros. I've tried opening a Numbers sheet and changing the format of the whole sheet to text before dragging the .csv file into the numbers document, as I saw another user did, but when done the inspector automatically changes back to "automatic" from "text". I also tried the user suggested idea of opening the file in text edit and finding and replacing all the "," with ",'" but then I got all my text surrounded with quotes. I then tried opening it up in NeoOfice (which is gifted enough to open a document properly, keeping leading zeros, but crashes every 10 min) and just put the "'" in just in front of column "A" to just force the primary key part numbers to text, but then all the other numbers don't hold there zeros, and I cant do this to 20 columns every time I want to do and export. I beg Apple or someone to find a solution to this problem. I would love to have the functionality of Numbers and finely kiss Office and NeoOffice goodbye.

Thanks,

Jeff

MacBook (Alum), Mac OS X (10.6.1)

Posted on Nov 1, 2009 5:17 PM

Reply
10 replies

Nov 1, 2009 6:55 PM in response to Jerrold Green1

But how do I open the .csv file to get the info. Is there a way to import data into pages from a .csv file? Even if there is I'm really not sure what you mean. I tried to do the find "," and replace with ",'" but then the already quoted text in my .csv file turned my quotes into text so all my discriptions for my parts looked like "Truck Part" (with the quotes). Thanks for your interest though. Maybe we can figure this out yet. So far my the closest thing to a solution is to open the .csv with neooffice because it actually allows you to select the format of the cells at import. Office allows something like this but they offer so many options I must be getting something wrong because whenever I export with office all my data gets screwed up.

Nov 1, 2009 7:37 PM in response to bainjeff

bainjeff wrote:
But how do I open the .csv file to get the info. Is there a way to import data into pages from a .csv file?


To open a csv file in Pages, change the suffix to txt and Pages will open it with no problem. You may have to use Get Info to set the default app to Pages for .txt files, but it's an easy thing to do.

I tried to do the find "," and replace with ",'" but then the already quoted text in my .csv file turned my quotes into text so all my discriptions for my parts looked like "Truck Part" (with the quotes).
bainjeff wrote:


I never said to use the quote symbol, I said Single-quote, by which I meant an apostrophe. Sorry if I wasn't clear. Adding an apostrophe after every Return character and substituting a TAB followed by an apostrophe for every comma-space directs Numbers to treat every piece of data as a text string. One little detail is that the first row in the first column will not be treated so you need to begin with an empty row.

Don't sound so ready to give up. This isn't that difficult.

edit: So, once you get your file edited in Pages, select the entire text block and Edit > Copy.

In Numbers, select a cell in the table where you want your data to begin; i.e., upper left corner. Then, Edit > Paste. Your data will move into this table. If the table isn't large enough, no matter, it will expand.

Good luck,

Jerry

Message was edited by: Jerrold Green1

Nov 1, 2009 7:45 PM in response to Jerrold Green1

I didn't use a quote I used quotes to indicate that I used an apostrophe. In my .csv file ever text is indicated by a begin and end quote so an example would be:

"00349","Truck Part","3.24",......

what I tried before from what you said in the other thread was to replace all commas with comma apostrophe to force everything text. For example:

"00349",'"Truck Part",'"3.24",......

Of course I added the apostrophe manually to the very beginning. But it left me with a spread sheet like this:

00349 | "Truck Part" | "3.24" | .......

I understand you said to add and apostrophe after every "return" I don't know what you mean by a "return" in a .csv file. My .csv file only had quotes to determine text and commas to indicate cell breaks. I'm assuming that's what you mean by a return. So the back to I can't replace commas with a comma and a apostrophe because that will turn the quotes indicating my text into text as well ie. "Truck Part"

I'm not sure what you meant by "substituting a TAB followed by an apostrophe for every comma-space". I want to understand you 🙂

Nov 2, 2009 8:28 AM in response to Jerrold Green1

Ok bud,
By record do you mean: me being the slowest person on earth, or this being the longest thread?

Anyway I think I have figured out how to make this work but I want to fully understand what your doing, as to learn as much as possible about this issue for future reference.

1. I start with a .csv file. How do you suggest I retrieve this data? You mention Pages but pages will not open a .csv file. However I was able to open the .csv file in textedit and work with it.

2.Do I understand you to say to replace the returns with a return and a apostrophe? If so how do you search for a return in find and replace? I tried option return but it just filled the whole filed with green. Is this a "return"?

3. I completely understand that your saying to replace all commas with a tab and an apostrophe.


However, last night I opened the .csv in textedit and simply replaced all commas with just a "Tab" and it seemed to separate all my data correctly. The only error was that any commas in my text had been converted into a tab. Once I had the Number sheet open I just found and replaced every "Tab" with a comma.

I just want to make sure that I'm doing this as "correctly" as possible because I can not afford to mess up the data and find out about it later.

Thank you so much Jerrold for your patience and help. I hope once I fully understand this concept I will be able to help others understand it as well to "pay it forward".

Jeff

Nov 3, 2009 12:06 AM in response to bainjeff

Hi Jeff,

I'm late to the party, but may be able to answer the specific questions in your most recent post.

bainjeff wrote:
1. I start with a .csv file. How do you suggest I retrieve this data? You mention Pages but pages will not open a .csv file. However I was able to open the .csv file in textedit and work with it.


If you can open the file in TextEdit and do the Find/Replace without problems, there's no need to open in in Pages.

If you need to open the file in Pages, the method is simple:
• Locate the file in the Finder.
• Click on the file's name, pause, then click again to make the name editable.
• Place the insertion point at the end of the filename and press delete (backspace) three times to remove the csv extension.
• Type txt to replace the file extension.
• Click outside the filename to leave editing mode.
• The Finder will probably present an alert warning that changing the suffix may result in the file being opened by a different application. Click to confirm that you want to change the suffix.

Right click (or ctrl-click) on the file's icon and choose Open with > Pages.

2.Do I understand you to say to replace the returns with a return and a apostrophe? If so how do you search for a return in find and replace? I tried option return but it just filled the whole filed with green. Is this a "return"?


In Pages, you can place a return in the Find or Replace boxes by pressing option-return. Also works for tab (option-tab).

This also works in TextEdit, but the Find/Replace dialogue does not display the symbols for these invisible characters.

3. I completely understand that your saying to replace all commas with a tab and an apostrophe.

However, last night I opened the .csv in textedit and simply replaced all commas with just a "Tab" and it seemed to separate all my data correctly. The only error was that any commas in my text had been converted into a tab. Once I had the Number sheet open I just found and replaced every "Tab" with a comma.


The commas in your data are the reason the CSV file included quotation marks to enclose each piece of data. Without the quotes, the data commas would be treated as separators.

To prevent changing data commas to tabs, change your search to find the three character string "," and replace it with tab'
You will also need to search "return" and replace with return'
And individually remove the quotation marks before the first piece of data and after the last piece(NOTE: tab and return above refer to the tab character and the return character, not the words "tab" and "return".)

I just want to make sure that I'm doing this as "correctly" as possible because I can not afford to mess up the data and find out about it later.


The best way to prevent messing up the data is to START by making a duplicate of the data file. Put the original in a safe place and work with the copy. Then if you do screw up the file you can go back to the original, copy it again, and continue to work with the (new) copy.

Regards,
Barry

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.

Leading Zeros

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