linux删除csv空格符号,删除csv fi中的换行符

您可以搜索后面跟不以“@”开头的行,例如\r?\n+(?!@\d+;)。在

以下是从regex101demo生成的。它用一个空格来代替这些行尾。你可以把它改成你喜欢的任何东西。在# coding=utf8

# the above tag defines encoding for this document and is for Python 2.x compatibility

import re

regex = r"\r?\n+(?!@\d+;)"

test_str = ("@4627289301; Lima, Peru; 490; 835551022915420161; Sat Feb 25 18:04:22 +0000 2017; \"\"[OJO!\n"

"la premiacin de los #Oscar, nuestros amigos de @cinencuentro revisan las categoras.\n"

"+info: co/plHcfSIfn8]\"\"; 0\n"

"@624974422; None; 114; 835551038581137416; Sat Feb 25 18:04:26 +0000 2017; \"\"[Porque nunca dejamos de amar]\"\"; 0")

subst = " "

# You can manually specify the number of replacements by changing the 4th argument

result = re.sub(regex, subst, test_str, 0, re.MULTILINE)

if result:

print (result)

# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值