Skip to content Skip to sidebar Skip to footer

Write A List Into Excel

I have a sentence 'And now for something completely different'. I want to tokenize it, tag it and store it into a excel file for further processing.
sent = 'And now for

Solution 1:

Excel files (xlsx) are not just simple flat files, so trying to copy a text file to xlsx will not work. You could save the file as csv and open it in Excel. I think pandas is really useful for parsing and writing data files (obviously it is also useful for processing data).

import pandas as pd
df = pd.DataFrame(tags)
df.to_excel('output.xlsx', header=False, index=False)

Solution 2:

Instead writing to excel format. You already writing your file into a tab-separated-value. Excel knows how to read that. I suggest you save your file with '.tsv' extension and open it in excel.


Post a Comment for "Write A List Into Excel"