Python Forum
Pytables : Printing without special characters - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Pytables : Printing without special characters (/thread-30802.html)



Pytables : Printing without special characters - Robotguy - Nov-06-2020

I create a dataset containing some file information (characters). Aim is to print the content. Using info[:] also prints special characters like \n, b. Is there a way to avoid print of these special characters? I know how to use a for loop and decode line-by-line, but that occupies extra space and looks clumsy in my code. Is there a clean/short alternative?

info = f.create_earray(f.root, "dataset_0", atom=tables.StringAtom(itemsize=200), shape=(0, ))
print(info[:]) # 

# reading line by line:
for i in range(info.shape[0]):  
    print(info[i].decode())