我有其中一栏为错误的数据框。在大多数情况下,该列没有值,但是在某些情况下,它确实会获得值。
当我在其上使用to_csv时,该列就像
Country,Etl_Batch,Input_Date,Input_CampaignID,Tags,TargetGroupID,CampaignType,Duration,LeadTime,Notes,IsMultiChannel,IsRecurrence,Status,Error,Api_Executed_Datetime
RO,1511293247,2019-07-02,4177,,89,No Control,1,0,,False,True,Successful,,2019-07-16 15:26:00.696304
RO,1511293247,2019-07-02,4178,,232,Test/Control,3,0,,False,False,Successful,"Exception caught at HTTPHelper postXMLHTTPSRequest. Http response: <?xml version=""1.0"" encoding=""UTF-8""?><error><code>UMS-105</code><description>'activities' is not specified or invalid</description><severity>ERROR</severity></error>
Error message: The remote server returned an error: (400) Bad Request. ",2019-07-16 15:26:00.696304
RO,1511293247,2019-07-02,4179,,-1,Test/Control,3,0,,False,False,Successful,,2019-07-16 15:26:00.696304
当我使用这些数据创建外部表时,我会遇到一个多碱基错误。
因为它有类似
的文字"Exception caught at HTTPHelper postXMLHTTPSRequest. Http response: <?xml version=""1.0"" encoding=""UTF-8""?><error><code>UMS-105</code><description>'activities' is not specified or invalid</description><severity>ERROR</severity></error>
Error message: The remote server returned an error: (400) Bad Request. "
这是一个字符串,但是由于它有""
(中间有两个双引号),因此会导致错误。
我必须从python的字符串中删除'""'
(两个双引号)。我该怎么办?
答案 0 :(得分:1)
使用此:
Jupyter Notebook
答案 1 :(得分:0)
您可以这样将“”替换为“
:yourString = "encoding=\"\"UTF-8\"\""
print(yourString)
yourString = yourString.replace("\"\"", "\"")
print(yourString)
输出:
encoding=""UTF-8""
encoding="UTF-8"