29 lines
1019 B
Python
29 lines
1019 B
Python
|
import csv
|
||
|
|
||
|
def check_languages_installed(from_code, to_code):
|
||
|
"""
|
||
|
Check if the language codes match the given criteria in a predefined .csv file.
|
||
|
|
||
|
Parameters:
|
||
|
- from_code (str): The source language code to check.
|
||
|
- to_code (str): The target language code to check.
|
||
|
|
||
|
Outputs:
|
||
|
- Prints True if a matching row is found, else prints False.
|
||
|
"""
|
||
|
try:
|
||
|
# Assuming the CSV file is named 'languages.csv' and located in the same directory
|
||
|
with open('installed_packages_info.csv', mode='r') as csv_file:
|
||
|
csv_reader = csv.reader(csv_file)
|
||
|
for row in csv_reader:
|
||
|
# Check if the current row matches the criteria
|
||
|
if len(row) >= 2 and row[0] == from_code and row[1] == to_code:
|
||
|
return True
|
||
|
# If the loop completes without finding a match, print False
|
||
|
return False
|
||
|
|
||
|
except FileNotFoundError:
|
||
|
return 1
|
||
|
except Exception:
|
||
|
return 1
|