我有一个文本文件,必须作为二进制读入才能工作。我正在尝试提取一些数据并放入csv文件。你知道吗
一些文本的示例如下所示:
b' "Title;""Date"";""Abstract"";""Patent Number"";""id"""\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"The object of my invention is to lessen the rapidity or amount of this diminution \t which I do by the addition of a new step in the process of making the lamp \t as follows : After the lamphas been exhausted of air and hermetically sealed by the fusion of the exhaust-tube in the usual manner \t I connect the lamp"";""12234"";"";1.0" '
我想在“;”之间提取片段,并尝试了以下操作:
contentRegex = re.compile(b'\s{4,}"([\w+\s]+);(\d{4})\.\d;""([\w+\s+]+)"(.+[^;])')
它似乎工作得很好,除了最后一部分,它在看到第一个“;”之后继续抓取文本。所以下面的正则表达式模式似乎是错误的:
(.+[^;])
我很感激任何帮助!你知道吗
谢谢
如果确实需要使用regexp,请尝试以下操作:
;(.*?);
或;([a-zA-Z"]*?);
相关问题 更多 >
编程相关推荐