22 lines
585 B
Python
22 lines
585 B
Python
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!') |