E_Commerce_Review_Engine/main.py

28 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def main():
print("\n======== Введите название файла с форматом .csv или используйте по умолчанию (Enter) ========")
name_report = input()
if not name_report:
name_report = "data.csv"
#проверка на правильность ввода имени файла
if name_report[-4:] == ".csv":
try:
report = open(name_report, 'r+', encoding='cp1251')
except:
print("Файл отсутствует")
else:
#запись файла в список
print("Содержимое файла:")
dec_report = list()
for i in report:
dec_report.append(i)
report.close()
print("id rating text")
for i in dec_report:
print(i)
else:
print("Неверный тип файла! "
"\nНеобходимо выбрать файл с форматом .csv")
if __name__ == "__main__":
main()