尝试创建一个公式,将由空格分隔的单词串转换为camelcase
答案 0 :(得分:6)
更小的版本:
Edittext
我们只使用<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:hint="@string/app_name" />
大写,=SUBSTITUTE(PROPER(TRIM(C8))," ","")
和PROPER
删除空格。
编辑:
似乎OP特别想要lowerCamelCase,只需TRIM
第一个小写的字符,我们有:
SUBSTITUTE
使用REGEX:
REPLACE
答案 1 :(得分:4)
为此,以下公式有效(其中A3
是单元格)
tl; dr :
=IF(IFERROR(FIND(" ",A3)), CONCAT(SUBSTITUTE(LEFT(LOWER(A3), FIND(" ", A3)), " ", ""), SUBSTITUTE(PROPER(SUBSTITUTE(A3, LEFT(A3, FIND(" ", A3)), "")), " ", "")), LOWER(A3))
注释:
=IF( // if a single word
IFERROR( // test if NOT an error
FIND( // looking for a space
" ",
A3
)
),
CONCAT( // concat the first word with the rest
SUBSTITUTE( // remove the space
LEFT( // left of the find
LOWER( // lowercase the string
A3
),
FIND( // find the space in the string
" ",
A3
)
),
" ",
""
),
SUBSTITUTE( // remove spaces
PROPER( // convert string to capitals
SUBSTITUTE( // remove first word
A3,
LEFT( // left of the find
A3,
FIND( // find first space
" ",
A3
)
),
""
)
),
" ",
""
)
),
LOWER( // lowercase rest of the word
A3
)
)
答案 2 :(得分:2)
这应该有效:
=JOIN("",ArrayFormula(UPPER(LEFT(SPLIT(A3," ")))&LOWER(MID(SPLIT(A3," "),2,500))))
或更确切地说:
=JOIN("",ArrayFormula(UPPER(LEFT(SPLIT(A3," ")))&
LOWER(REGEXEXTRACT(SPLIT(A3," "),".(.*)"))))
答案 3 :(得分:1)
从所有答案中获取线索,分享我所做的事情,因为没有人以下面的确切方式提及它(例如,created_at => createdAt
的转化)
=REPLACE(SUBSTITUTE(PROPER(A5), "_", ""), 1, 1, LOWER(LEFT(A5, 1)))
上面的公式是
除最后一部分用小写字母替换第一个字符外,大部分工作都使用PROPER函数完成
答案 4 :(得分:0)
如果您要变成驼峰式的单词的字符串包含在A1中,则公式非常简单:
with open("otuput.csv",'r') as f:
arr=list(csv.reader(f, delimiter=","))
arr = np.array(arr[1:], dtype=object)
uniqueValues= np.unique(arr, return_counts=True)
vectorizer = CountVectorizer()
X = vectorizer.fit_transform(uniqueValues)
print (X)
print (vectorizer.get_feature_names())