Ответы пользователя по тегу LibreOffice
  • Как перемножить текстовые значения столбцов?

    yarkov
    @yarkov Куратор тега JavaScript
    Помог ответ? Отметь решением.
    names.txt
    Иван
    Степан


    father_names.txt
    Иванович
    Степанович


    combine.py
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    names_file = 'names.txt'
    father_names_file = 'father_names.txt'
    combinations_file = 'combinations.txt'
    
    def main():
        with open(combinations_file, 'w') as combinations:
            with open(names_file, 'r') as names, open(father_names_file, 'r') as father_names:
                names_lines = names.readlines()
                father_names_lines = father_names.readlines()
                for name in names_lines:
                    for father_name in father_names_lines:
                        line = "%s %s" % (name.replace("\n", ""),
                                          father_name.replace("\n", ""))
                        combinations.write("%s\n" % line)
    
    if __name__ == '__main__':
        main()


    combinations.txt
    Иван Иванович
    Иван Степанович
    Степан Иванович
    Степан Степанович
    Ответ написан
    2 комментария