How to get only the numbers(without whitespaces) from a text file in python
<p>Hello i have this text file:</p>

<pre><code>1 2 3 4 5 6
1 1 1 1 1 1
-1 1 -1 -1 -1 1
2 3 5 6 1 6
10 0 0.5 1 0 0
0 30 5 3 0 0
0 0 0 0 0 5
80 90 6 5,4 8 5
65 58 2 9,7 1 1
83 60 4 7,2 4 7
40 80 10 7,5 7 10
52 72 6 2 3 8
94 96 7 3,6 5 6
</code></pre>

<p>I want to append the 7 first lines in 7 different lists( with a for loop if it is possible) to look like this:</p>

<pre><code>a=[1 2 3 4 5 6]
b=[1 1 1 1 1 1]
</code></pre>

<p>and so one for the rest 5. And then i want the remaining 6 lines of the file to be appended in to a list of list with a for loop(so that if i have more than 6 remaining lines, the code would not change) like this:</p>

<pre><code>mylol=[[80 90 6 5,4 8 5],[65 58 2 9,7 1 1],[83 60 4 7,2 4 7],[40 80 10 7,5 7 10],[52 72 6 2 3 8],[94 96 7 3,6 5 6]]
</code></pre>

<p>so that i will be able to use every number of every list of list as i want for mathematical operations. I noticed that in the end of the list of lists i try to make i have a list looking like this:</p>

<pre><code>['']   
</code></pre>

<p>and i dont want it if it is possible.</p>

<p>I have this code so far but i want something more like the one i ask for:</p>

<pre><code>with open("c.txt") as file:
lines = []
for line in file:
    # The rstrip method gets rid of the "\n" at the end of each line
    lines.append(line.rstrip().split(","))
print lines
</code></pre>