please in need your help , i wanrt to compy some specific lines from a file to another two ones. the variables n and p are global . here is my code :
def files():
i = 1
X = 1
f90 = open('C:\Users\Homura\Desktop\python\data90.txt' , 'w')
f10 = open('C:\Users\Homura\Desktop\python\data10.txt' , 'w')
f = open('C:\Users\Homura\Desktop\python\TData.txt' , 'r')
while True:
line = f.readline()
if line.startswith('0'):
while i <= n: # taking 90% of negative tweets and writing them in f90
f90.write(line)
i += 1
while i != n: #putting the rest of the negative tweets ( 10%) in the f10 file
f10.write(line)
i += 1
elif line.startswith('1'):
while ( x <= p): # taking 90% of positive tweets and writing them in f90
f90.write(line)
x += 1
while (x != p): #putting the rest of the positive tweets ( 10%) in the f10 file
f10.write(line)
x += 1
f.close()
f10.close()
f90.close()
return f10 , f90