Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import os
  2. import sys
  3. import csv
  4.  
  5. AMplateNum = input("Please Scan AM-DNA plate barcode AM******-DNA: ")
  6. NormFileName = AMplateNum + ".txt"
  7. FileToChange = "E:\NormalizeData\" + NormFileName
  8. #this prompts user to scan in AM barcode then builds the file path
  9.  
  10. def check_value_to_edit(value):
  11. if float(value) > 353.7000:
  12. value = "353.7000"
  13. return value
  14. else:
  15. return value
  16. #check_value_to_edit evaluates a "value" as a float and changes it to 353.7
  17. #if the value exceeds it
  18. def get_destination_dictwriter(file):
  19. with open(FileToChange, 'r') as source:
  20. csv_source = csv.DictReader(source, delimiter='t')
  21. fieldnames = csv_source.fieldnames
  22. dictwriter = csv.DictWriter(file, fieldnames=fieldnames)
  23. return dictwriter
  24.  
  25. destination = open(FileToChange, 'w', newline='')
  26. csv_destination = get_destination_dictwriter(destination)
  27.  
  28. with open(FileToChange, 'r') as source:
  29. csv_source = csv.DictReader(source, delimiter='t')
  30. for row in csv_source:
  31. row["Concentration"] = check_value_to_edit(row)
  32. csv_destination.writerow(row)
  33.  
  34.  
  35. destination.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement