A question on the creation of list of lists
subhabrata.banerji at gmail.com
subhabrata.banerji at gmail.com
Wed Apr 22 12:18:30 EDT 2015
Dear Group,
I am trying to open a bunch of files from a directory and trying to put the results in list of lists that is to say,
that is to say,
I have a list of file names of a directory, I want to read each one of them.
After reading each one of them, I want to put the results of each file in a list.
These lists would again be inserted to create a list of lists.
to do this I am trying to write it as follows:
list_of_files = glob.glob('C:\Python27\*.*')
print list_of_files
list1=[]
list2=[]
list_N=[list1,list2]
for i,j in zip(list_of_files,list_N):
print i,j
x1=open(i,"r").read()
x2=j.append(x1)
all_sent=list_N
print all_sent
Am I doing anything wrong? If any one may kindly suggest?
Is there any smarter way to do it? I am using Python2.7+
on MS-Windows 7 Professional Edition.
Apology for any indentation error.
Regards,
Subhabrata Banerjee.
More information about the Python-list
mailing list