SHARE
TWEET

Untitled

a guest Jun 25th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. input_file = r"C:\\Users\esf\Desktop\ExcelviaPython\AsReceived.txt"
  2. output_file = r"C:\\Users\esf\Desktop\ExcelviaPython\UniqueValues.txt"
  3.  
  4. with open(input_file) as in_file:
  5.     counter = 0
  6.  
  7.     ListIncludingDupes = []
  8.     UniqueList = []
  9.     for line in in_file.readlines():
  10.  
  11.         numsemicolons = line.count(";")
  12.  
  13.         if numsemicolons == 0:
  14.             ListIncludingDupes.append(line)
  15.         else:
  16.             linelist = line.split(";")
  17.             for line_element in linelist:
  18.                 line_element.strip()
  19.                 ListIncludingDupes.append(line_element)
  20.  
  21.  
  22.         for potential_unique in ListIncludingDupes:
  23.             if potential_unique == '\n':
  24.                 continue
  25.             elif potential_unique.strip() not in UniqueList:
  26.                 UniqueList.append(potential_unique.strip())
  27.             else:
  28.                 continue
  29.  
  30.  
  31.  
  32. with open(output_file, "a") as out_file:
  33.     UniqueList.sort()
  34.     for value in UniqueList:
  35.         out_file.write('%s\n' % value)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top