Python reading a file line by line and sending it to another Python script
<p>Good day.</p>

<p>Today i was trying to practice python and Im trying to make a script that reads the lines from a file containing only numbers and using said numbers as a parameter in another Python script.</p>

<p>Here at work i sometimes need to execute a python script called Suspend.py, ever time i excute this scripit i must type the following information:</p>

<pre><code>Suspend.py suspend telefoneNumber
</code></pre>

<p>I have to do this procedure many times during the day and i have to do this for every number on the list, it is usually a very long list. SO i though on trying to make things a little bit faster and creat a Python script myself.</p>

<p>Thing is a just started learning Python on my own i kinda suck at it, so i have no idea on how to do this.</p>

<p>In one file i have the following numbers:</p>

<pre><code>87475899
87727856
87781681
87794922
87824499
88063188
88179211
88196532
88244043
88280924
88319531
88421427
88491113
</code></pre>

<p>I want python to be able to read line by line and send this number to another file script together with the word "suspend" on the previously said python script.</p>

<p>If I understand you correctly:</p>

<pre><code>import subprocess

with open("file_with_numbers.txt") as f:
    for line in f:
        subprocess.call(["python", "Suspend.py", "suspend", line.strip()])
</code></pre>

python