For example the if[count][2] reads the DNP column and writes the column to the left of it into Ref1. The if statement doesn't work if the column next to the DNP is multiple varibles like 'R20,R30'.
How do you write an if statement that reads multiple inputs?
import os
import os.path
import csv
directory_exists1 = False;
f_exists1 = False;
while (directory_exists1 == False or f_exists1 == False):
file_path1 = input('Please Enter The Directory Of The .emn File With Back_Slashes /: ')
directory1 = os.path.dirname(file_path1)
file_name1 = os.path.basename(file_path1)
directory_exists1 = os.path.isdir(directory1)
if directory_exists1 == False:
print("Incorrect directory")
f_exists1 = os.path.isfile(file_name1)
if f_exists1 == False:
print ("Incorrect file name")
import shutil
os.chdir(directory1)
shutil.copy(directory1+'/'+file_name1,directory1+'/'+"new"+file_name1)
inputfile = open(file_name1)
newfile = open('new'+file_name1,'w')
mytext = inputfile.readlines()
print("")
directory_exists = False;
f_exists = False;
while (directory_exists == False or f_exists == False):
file_path = input('Please Enter The Directory Of The csv File With Back_Slashes /: ')
directory = os.path.dirname(file_path)
file_name = os.path.basename(file_path)
directory_exists = os.path.isdir(directory)
if directory_exists == False:
print("Incorrect directory")
f_exists = os.path.isfile(file_name)
if f_exists == False:
print ("Incorrect file name")
import shutil
os.chdir(directory)
shutil.copy(directory+'/'+file_name,directory+'/'+"new"+file_name)
inputfile2 = open(file_name)
newnewfile = open('new'+file_name,'w')
csv_inputfile = csv.reader((inputfile2),
delimiter=',')
data = list(csv_inputfile)
##i=1
for count in range(len(data)):
## for count in range(0,len(Ref1)):
## print (Ref1)
## Ref1 = Ref1[i:i+count]
if data[count][2] == 'DNP':
Ref1 = data[count][0]
##Ref1 = Ref1.split(",")
print (Ref1)
for count in range(len(mytext)-1,0,-1):
if Ref1 in mytext[count]:
del mytext[count]
del mytext[count]
for lines in mytext:
newfile.write(lines)
print('ENDED!')