On 27/10/2015 21:32, jarod_v6--- via Tutor wrote:
Hi!
I want to reads two files and create simple  dictionary.  Input file contain 
more than 10000 rows


diz5 = {}
with open("tmp1.txt") as p:
     for i in p:
         lines = i.rstrip("\n").split("\t")
         diz5.setdefault(lines[0],set()).add(lines[1])

diz3 = {}
with open("tmp2.txt") as p:
     for i in p:
         lines = i.rstrip("\n").split("\t")
         diz3.setdefault(lines[0],set()).add(lines[1])

how can manage better this reading and writing?
thanks so much


https://docs.python.org/3/library/csv.html
https://docs.python.org/3/library/csv.html#csv.DictReader
https://docs.python.org/3/library/csv.html#csv.DictWriter
https://docs.python.org/3/library/csv.html#csv.excel_tab

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to