Skip to content

Instantly share code, notes, and snippets.

@proteusvacuum
Last active November 5, 2015 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save proteusvacuum/11b1fd45891c134dba1b to your computer and use it in GitHub Desktop.
Save proteusvacuum/11b1fd45891c134dba1b to your computer and use it in GitHub Desktop.
#!/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)
writer.writerows(rows)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment