How to read values from from a text file with columns?
<p>I'm trying to read data from a file that is separated in columns with data from each year and lines with the name of the values (eg:number of times I opened Firefox on the year 2015). Now, I know how to read a specific line but I'm having trouble reading from the different columns. They are 10 spaces wide but only have values like -0.5 and 1.2, so it doesn't get to the tenths and only 1 decimal. Like this:</p>

<pre><code>-3.5         1.0        -2.9         6.8
</code></pre>

<p>How would I do it to read these values since I have to compare them as floats to other data? Would I slice it? If so I haven't found a way to do so.</p>

<p>Once you've got your line in a string, the simplest would be to split the string on the whitespace.</p>

<pre><code>values = line.split()
</code></pre>

<p>The iterate through that list and cast to a float.</p>

<pre><code>float_values = [float(v) for v in values]
</code></pre>

python slice