简体   繁体   English

替换多个特殊字符

[英]Replacing multiple special characters

I want to get rid of multiple special characters that might show up in a specific column and replace it with a space but I keep getting this error when I try to write my file to an excel document. 我想摆脱可能出现在特定列中的多个特殊字符,并用空格替换它,但是当我尝试将文件写入excel文档时,我一直收到此错误。

Exception: Invalid Excel character '[]:*?/\' in sheetname 'AL DINTE LASA/JACKY'S'

I have already tried the below but it is not working but I dont know why that should get rid of multiple special characters and then replace it with an underscore. 我已经尝试过下面的方法,但是它不起作用,但是我不知道为什么应该除去多个特殊字符,然后将其替换为下划线。

 df['Name'].replace(["/''//'-[]:*?/\\/#",'_'],regex=True)

I dont know what else to try I cant seem to get around this error, am I just not using df.replace correctly? 我不知道还有什么尝试可以解决这个错误,我只是没有正确使用df.replace吗?

The problem is not in the spreadsheet data itself - it is in the name of the spreadsheet. 问题不在于电子表格数据本身,而在于电子表格的名称。 Specifically, the slash is not allowed in the sheetname. 具体来说,工作表名称中不允许使用斜线。 You can change the name to "AL DINTE LASA-JACKY'S" and it should work fine. 您可以将名称更改为“ AL DINTE LASA-JACKY'S”,它应该可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM