[Tutor] Help Please

Mario Ontiveros ontiveros at dawson3d.com
Wed Feb 20 09:30:16 EST 2019


Hello,
    I am new to python and have been stuck on this for a while. What I am trying to do is to remove rows with void, disconnected, and error on lines. The code I have does that, the only problem is that it removes my header because void is in header. I need to keep header.

Any help will be greatly appreciated.

with open("PSS.csv","r+") as f:
    new_f = f.readlines()
    f.seek(0)
    for line in new_f:
        if "Void" not in line:
            if "Disconnected" not in line:
                if "Error" not in line:
                 f.write(line)
    f.truncate()



Mario Ontiveros


---------------------------------------------------------------------------------------
Confidentiality Warning: This message and any attachments are intended only for the 
use of the intended recipient(s), are confidential, and may be privileged. If you are 
not the intended recipient, you are hereby notified that any review, retransmission, 
conversion to hard copy, copying, circulation or other use of all or any portion of 
this message and any attachments is strictly prohibited. If you are not the intended 
recipient, please notify the sender immediately by return e-mail, and delete this 
message and any attachments from your system.
---------------------------------------------------------------------------------------


More information about the Tutor mailing list