Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python
import csv
def main():
translations = {}
with open('messages_en-2.txt', 'rb') as translation_file:
translation_reader = csv.reader(translation_file, delimiter="=")
for row in translation_reader:
if len(row) > 1:
translations[row[0]] = row[1]
with open('bulk_ui_translations_no_change.csv', 'rb') as csvfile:
table = csv.reader(csvfile)
rows = [row for row in table]
for row in rows:
translation = translations.get(row[0], None)
if translation:
row[1] = translation
rows = [row for row in rows if translations.get(row[0], False)]
with open('output.csv', 'wb') as output_file:
writer = csv.writer(output_file)
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment