directory = raw_input("INPUT Folder:")
output = raw_input("OUTPUT Folder:")
txt_files = os.path.join(directory, '*.txt')
for txt_file in glob.glob(txt_files):
filename = os.path.splitext(os.path.basename(txt_file))[0] + '.csv'
with open(txt_file, "rb") as input_file, open("book.csv", 'a') as output_file:
out_csv = csv.writer(output_file)
lines = input_file.readlines()
for i in range(0, len(lines)):
if i==len(lines):
out_csv.writerow(lines)
else:
lines.append(lines[i+1])
i am trying to open the text files in movie review data base and convert it such that the total data in a text file should come as one row in csv i.e. the neg folder in movie review consist of 1000 file thn my csv should contain 1000 rows of all text each row corresponding to complete text of one file please help me i have tried various ways but it gives some error or the other ,with this code it is givivng error as
Traceback (most recent call last): File "C:\Python27\preprocessing adding adnan.py", line 51, in lines.append(lines[i+1]) IndexError: list index out of range