Capitals change to lower case in CSV

I have a column in a Numbers spreadsheet that contains the names of countries in lower case, like this...


canada

united-states

mexico


I created a new column, copied this column into it, then started changing the names to proper place names, like this:


Canada

United States

Mexico


Then I discovered Numbers' Title command - Format > Font > Capitalization. So I used that to finish the job. Then I exported it as a CSV file.


But when I import it into my revised database table, many of the names revert to lower case (including every instance of "mexico").


I can fix my database table easily enough, but the next time I import data into it, I'll have to fix the same lower case letters again. Can anyone tell me what's going on here and how I can fix it?


Thanks.

OS X Mavericks (10.9.2)

Posted on Jun 2, 2014 1:04 PM

Reply
5 replies

Jun 2, 2014 1:21 PM in response to Chavista

When you use that command I suspect that it is applying a format to the cells which cannot be stored in a CSV file which is purely text.


If you want to change the capitalization then copy the content of the country column. Paste into text edit ( or some other program to "lock" the capitalization. I used Mail), then copy and paste back to the spreasheet. Then export back to a csv file.

Jun 3, 2014 6:00 AM in response to Chavista

I tried to post some code for Automator service but failed due to the following error.


Access Denied

You don't have permission to access "http://discussions.apple.com/post.jspa?" on this server.


It seems some content filtering is blocking post containing certain character or character sequence.


Anyway, I cannot help when the board system rejects helper in such a way. 😟


Regards,

H

Jun 3, 2014 7:21 AM in response to Chavista

Numbers displays the values as capitalized, but the underlying values (the values that are exported) are unchanged.


To capitalize the underlying values you can select the cells with the country names and run the script below (paste into AppleScript Editor and click the green triangle 'run' button).


This works with Numbers 3.2. If you are using Numbers 2.3, post and I'll provide modified script.


SG



--converts cell contents to "Title" case; to use, select cells, click 'run' button

try

tell application "Numbers"

set t to front document's active sheet's first table whose selection range's class is range

tell t's selection range to repeat with aCell in cells

set aCell's value to my changeCase(aCell's value, "title")

end repeat

end tell

on error

display alert "Problem. Did you select all non-blank cells before running?" buttons "Cancel"

end try


to changeCase(someText, caseType)

do shell script "/usr/bin/python -c \"import sys; print unicode(sys.argv[1], 'utf8')." & caseType & "().encode('utf8')\" " & quoted form of someText

end changeCase

--end of script

Jun 3, 2014 1:33 PM in response to Hiroto

An idea flashed on me that the interpreter name / b i n / b a s h (without spaces) is the phrase letting the fora software deny the post. So I try the idea. Here goes the amended version.


---

Hello


IMHO, Format > Font > Capitalization is one of the most confusing features of Numbers and Pages. It never change the text data itself but only the text "appearance" just as changing font does nevertheless the text case is not the matter of glyphs but the code points. This is the reason why you see the said behaviour.


E.g., enter loweccase text, apply Format > Font > Capitalization > Title, copy the text, paste into TextEdit and you'll see the lowecase text.


In order to preserve the capitalization between applications, that includes exporting to CSV, text must consists of exact code points of coded character set which by design implements character case by distinct code point.


There're several ways to realise that and here I'd like to present a method using services. If you have already installed any text services that can change text case, just use it. Otherwise it is simple to create your own services using Automator.app. Recipe is as follows.


1) Launch Automator.app, select Service template, add Run Shell Script action (from left pane to right workflow editor pane).


2) Set service's properties such that

Service receives selected [text] in [any application]

Replaces selected text [checked]


3) Set Run Shell Script action's properties such that

Shell = / b i n / b a s h (actually without spaces inbetween)

Pass input = as arguments

Code =


perl -CSDA -pe 's/\b\w+/\u\L$&/g' <<< "$@"



Now service workflow looks like this:


User uploaded file



4) Save the service workflow with descriptive name such as "change case to Title Case".



In order to use the service, first select text in any application and select the service from [Application] > Services menu.


In Numbers.app, for example, you may copy the column, paste it into a new text box, select the text in the text box, call the service and the text will be replaced with Title Cased text. Then copy the converted text and paste to the original column. Done.


Of course, you may copy the column in Numbers to TextEdit, apply the service in TextEdit and copy it back to the column in Numbers.


If you wish you may assign keyboard shortcut for the service by using System Prefenencs.



---

You may also create services for lowercase and UPPERCASE by changing the code for Run Shell Script action as follows.


For lowercase (change case to lowercase):


perl -CSDA -pe 's/\b\w+/\L$&/g' <<< "$@"



For UPPERCASE (change case to UPPERCASE):


perl -CSDA -pe 's/\b\w+/\U$&/g' <<< "$@"



Hope this may help,

H



PS. Bingo. / b i n / b a s h (without spaces) is being filtered. But why ???.


Message was edited by: Hiroto (added PS)

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.

Capitals change to lower case in CSV

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