Dec-28-2018, 01:07 PM
(Dec-28-2018, 02:56 AM)woooee Wrote: The will write only the last record (str2) because the write statement is outside the forHad it been outside for loop it would not have written anything since it's writing but line numbers are not coming correctly that is the main problem here and i am unable to understand why it's picking up incorrect line numbers.
for num, line in enumerate(name, 1): if excel_word[i] in text_string1: cnt[excel_word[i]] += 1 str2="|"+excel_word[i]+" "*(20-len(excel_word[i]))+"|"+os.path.join(root, name)+" "*(200-len(os.path.join(root, name)))+"|"+str(num)+" "*(10-len(str(num)))+"|" +"\n" else: cnt[excel_word[i]]+=0 FO.write(str2)
Is there any option available to upload output file(text file) on this forum?
if yes, then how to upload it here on this forum so that every one could understand that it's writing wrong line number in the text file report based on above code snippet.
Thanks