'I want to check if the .csv file contains the exact data without any leading and trailing spaces
I changed the code to this. Can someone tell me what is the keyword i should use to remove spaces(trailing and leading. Something is not working. I cant figure out what. Also, I am getting a ',' in the end of the string for ex: [' This is supp_info with leading and trailing spaces ',]
def check_if_report_contains_required_info(self, rule, *required_info):
supp_info = [] // column having actual information in report (.csv file)
missing_info = [] // information i am expecting to be in report (.csv file)
with open(self._results_file, 'r') as f:
file_content = f.readlines()
for line in file_content:
if re.search(r"^{}$".format(rule), line.split(',')[6].strip()):
supp_info.append(line.split(',')[-1].strip())
if not str(required_info)[2:-3] in str(supp_info):
raise Exception(f"Supplemental info does not contain required informations: {missing_info}")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|