Read multiple .txt files in a single folder
<p>I want to read from multiple .txt file in a single folder, and read every line as a list.</p>

<p><a href="https://i.stack.imgur.com/ATODO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ATODO.png" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/gWYlU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gWYlU.png" alt="enter image description here"></a></p>

<p>This is my code, however it prints nothing. </p>

<pre><code>import glob
import errno
path = '/Users/xccxken/PycharmProjects/untitled7/NNRelease/*.txt'
files = glob.glob(path)
for name in files:
    try:
        with open(name) as f:
            for line in f:
                words = list()
                for word in line.split():
                    words.append(word)
    except IOError as exc:
        if exc.errno != errno.EISDIR:
            raise
    print(words)
</code></pre>

<p>I hope the resulting is two lists a and b</p>

<pre><code>a=[class,company,family,..]
b=[size, size, size,...]
</code></pre>

<p>Another question is the print lists contains some empty lists, (I think it is because the original txt files has empty row) Please tell me how to remove these empty lists. Thanks!</p>

<p>In addition, I need to delete the lists that contain "#” thanks!</p>