Search code examples
pythonregexknime

I am trying to filter a database table with rows of .html files, but getting the error: TypeError: expected string or bytes-like object


Basically I am trying to filter a colum of my database table, which contains the content of several thousands HTML files.

When I am trying this, I am getting this error:

TypeError: expected string or bytes-like object.

So I tried to convert the content of all rows of the column with:

input_table [["Document"]] = input_table[["Document"]].astype(str)

Since I am working with knime the output data table tells me that the output data type of the column is a string.

But when I am using this Regex with Python:

import re


text = re.findall("^<span", str)

I am getting the aforementioned error.

Somebody can help with this?

Thank you.


Solution

  • This line is wrongly written in python:

    input_table [["Document"]] = input_table[["Document"]].astype(str)
    

    In python this should be:

    input_table ["Document"] = input_table["Document"].astype(str)
    

    this should convert your column into string.