何らかの理由で、Excelセル内のテキストが、cell.value
としてのみ読み込み可能です。Pythonを使ってregexを `cell.value`にマッチさせますか?
emailRegex = re.compile(".*?([a-zA-Z0-9\._%+\-][email protected][a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4}).*?")
私は試してみてください。
for row in ws.iter_rows():
for cell in row:
if emailRegex.match(cell.text):
mail = emailRegex.match(cell.text).group[0]
cell.text = mail
customeremails.append(mail)
print(customeremails)
AttributeError: Object has no str
for row in ws.iter_rows():
for cell in row:
if emailRegex.match(str(cell.value)):
mail = emailRegex.match(str(cell.value)).group[0]
cell.text = mail
customeremails.append(mail)
print(customeremails)
SyntaxError: invalid syntax
は現在、8時間の解決策を見つけることを試みて。
編集:
エラーとemailRegexが更新されました。また
:
for row in ws.iter_rows():
for cell in row:
content = cell.text
print(content)
は、セルが何列
for row in ws.iter_rows():
for cell in row:
content = cell.value
print(content)
が含まれていないというエラーを与えるには、以下を与える:(中略)
None
None
4020110
None
Nagdevi
None
Mumbai
完全なエラーメッセージを表示してください。 – BrenBarn
'emailRegex'とは何ですか? – 2ps
'group'はマッチ結果の関数です。 – 2ps