przetwarzanie_jezyka_natura.../B/BO2.py

22 lines
585 B
Python
Raw Normal View History

2022-11-05 19:53:13 +01:00
import regex as re
def is_line_correct(line: str) -> bool:
result = re.match(r'^.+;\d+;\d+$', line)
return True if result else False
def is_correct_csv(file_name: str) -> bool:
file = open(file_name, 'r')
is_correct = True
for line in file:
is_correct = is_correct and is_line_correct(line)
if not is_correct:
break
file.close()
return is_correct
if __name__ == '__main__':
file_n = input('Podaj nazwe pliku csv: ')
print('Plik CSV jest poprawny!') if is_correct_csv(file_n) else print('Plik CSV jest niepoprawny!')