Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import csv
- AMplateNum = input("Please Scan AM-DNA plate barcode AM******-DNA: ")
- NormFileName = AMplateNum + ".txt"
- FileToChange = "E:\NormalizeData\" + NormFileName
- #this prompts user to scan in AM barcode then builds the file path
- def check_value_to_edit(value):
- if float(value) > 353.7000:
- value = "353.7000"
- return value
- else:
- return value
- #check_value_to_edit evaluates a "value" as a float and changes it to 353.7
- #if the value exceeds it
- def get_destination_dictwriter(file):
- with open(FileToChange, 'r') as source:
- csv_source = csv.DictReader(source, delimiter='t')
- fieldnames = csv_source.fieldnames
- dictwriter = csv.DictWriter(file, fieldnames=fieldnames)
- return dictwriter
- destination = open(FileToChange, 'w', newline='')
- csv_destination = get_destination_dictwriter(destination)
- with open(FileToChange, 'r') as source:
- csv_source = csv.DictReader(source, delimiter='t')
- for row in csv_source:
- row["Concentration"] = check_value_to_edit(row)
- csv_destination.writerow(row)
- destination.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement