23 lines
846 B
Python
23 lines
846 B
Python
|
import argostranslate.package
|
||
|
import csv
|
||
|
|
||
|
|
||
|
# Function to write installed package details into a CSV file
|
||
|
def write_installed_packages_to_csv(filename='data/installed_packages.csv'):
|
||
|
# Fetch all installed packages
|
||
|
installed_packages = argostranslate.package.get_installed_packages()
|
||
|
# Open/Create a CSV file to write into
|
||
|
with open(filename, mode='w', newline='', encoding='utf-8') as file:
|
||
|
writer = csv.writer(file)
|
||
|
|
||
|
# Write package details row by row
|
||
|
for package in installed_packages:
|
||
|
from_language = package.from_code
|
||
|
to_language = package.to_code
|
||
|
package_name = package.from_name
|
||
|
|
||
|
writer.writerow([from_language, to_language, package_name])
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
write_installed_packages_to_csv()
|
||
|
|