Skip to content

Writing a tab-separated file #1

@montesmariana

Description

@montesmariana

This is the code we saw earlier:

split_st_1 = ["Sentence1", "Sentence2", "Sentence3"] # list of lines of one text
split_tt_1 = ["Oración1", "Oración2", "Oración3"] # list of lines of the other text
with open("translation_memory.csv", "w", encoding = "utf-8") as f: # open file to overwrite
    f.write("EN\tES\n") # write heading
    for x, y in zip(split_st_1, split_tt_1): # go through each pair of lines
        f.write(f"{x}\t{y}\n") # write the line

When you open it later with pandas, remember to specify that the separator is '\t'!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions