Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit b85dc7a

Browse files
committed
writes column date in worksheet into text files
1 parent 386e29e commit b85dc7a

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
import openpyxl
3+
4+
5+
def toTextFiles(filename):
6+
"""writes column data in worksheet into text files
7+
Args:
8+
filename (str): name of worksheet to read from
9+
Returns:
10+
None
11+
"""
12+
wb = openpyxl.load_workbook(filename)
13+
sheet = wb.active
14+
count = 1
15+
16+
for colObj in sheet.columns:
17+
18+
with open('text-'+str(count)+'.txt', 'w') as file:
19+
for cellObj in colObj:
20+
file.write(cellObj.value)
21+
22+
count += 1
23+
24+
25+
if __name__ == "__main__":
26+
toTextFiles('worksheet.xlsx')
5.02 KB
Binary file not shown.

0 commit comments

Comments
 (0)