Stuff spaces at end of lines in file
<p>I am trying to read a fixed with file that has lines/records of different lengths. I need to stuff spaces at the end of the lines which are less than the standard length specified.</p>

<p>Any help appreciated.</p>

<p><a href="http://i.stack.imgur.com/N5Kbd.png" rel="nofollow">enter image description here</a></p>

<p>You could consider to use ljust string method.
If line is a line read from your file:</p>

<pre><code>line = line.ljust(50)
</code></pre>

<p>will stuff the end of the line with spaces to get a 50 characters long line. If line is longer that 50, line is simply copied without any change.</p>

python fixed-width