def _creating_csv_reader(custom_word = 'кидать'): ngram_url = ngram_tools.choose_right_ngram_url(custom_word) try: source_csv = open(ngram_url.split('/')[-1][:-3]+'.csv', 'r+',newline='') except IOError: try: p = subprocess.Popen([sys.executable,"creating_word_specified_csv.py",custom_word]) p.communicate() source_csv = open(ngram_url.split('/')[-1][:-3]+'.csv', 'r+',newline='') except FileNotFoundError: sys.exit("script failed to create") return csv.reader(source_csv, delimiter=',',quotechar='"', quoting=csv.QUOTE_MINIMAL)
def main(): _creating_specified_csv(_get_word_from_parameters(), _open_source_tsv( ngram_tools.choose_right_ngram_url(_get_word_from_parameters())), _creating_csv_writer( ngram_tools.choose_right_ngram_url(_get_word_from_parameters())))