I am new to python and try to use write the excel data into a text file with a specific format. But somehow I am facing a problem with duplication of data.
f = open("test1.txt", "a+") # Text
file create here
f5 = []
i = []
j = []
flag = False
for sheet in allSheetNames:
currentSheet = theFile[sheet]
for row in range(2, currentSheet.max_row + 1):
for column in "ABCDEF":
cell_name = "{}{}".format(column, row)
if currentSheet[cell_name].value == None:
j = I
flag = True
else:
f.write("{}".format(currentSheet[cell_name].value))
i = cell_name
flag = True
#if flag == True:
#if j != I:
# print("{}".format(currentSheet[i].value))
#flag = False
f.close()
exit()
The committed part actually I am trying to compare the column number and similar column number is trying to avoid `enter code here duplication.
Here is the text file which actually I required as an output.
enter image description here
enter image description here
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…