-1

Anyone knows how to create a xls file from a dict? I have a dictionary filled with words in a text, i want to put this DICT in a xls

def contar_Repetidas(texto):
    dic={}
    l=texto.split()
    for palabra in l:
        if palabra not in dic:
            dic[palabra] = 1
        else:
            dic[palabra] +=1
    return dic

It's diferent becorse, i want to create a MS Excel from a DICT, a DICT

1
  • its not duplicate,only XLS Commented Aug 26, 2013 at 16:47

1 Answer 1

2

Using the xlwt module:

import xlwt

dic = contar_Repetidas("Some Text Here")

wb = xlwt.Workbook()
ws = wb.add_sheet("Your Sheet")

count = 0
for word, num in dic.items():
    count += 1
    ws.write(count, 1, word)
    ws.write(count, 2, num)

wb.save("/Path/To/Save/Example.xls")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.