summaryrefslogtreecommitdiff
path: root/Chapter12PracSpreadsheetToText.py
diff options
context:
space:
mode:
authormlot <petri-rush-curvy@duck.com>2025-06-06 13:40:57 -0400
committermlot <petri-rush-curvy@duck.com>2025-06-06 13:40:57 -0400
commit75a42ec54dbf721caa659ddf02c1f46fc2cb4bef (patch)
tree84be794a2481e356a7784557a6f9fb6fbf29cfdd /Chapter12PracSpreadsheetToText.py
initial commit for archivingHEADmain
Diffstat (limited to 'Chapter12PracSpreadsheetToText.py')
-rw-r--r--Chapter12PracSpreadsheetToText.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Chapter12PracSpreadsheetToText.py b/Chapter12PracSpreadsheetToText.py
new file mode 100644
index 0000000..3fcc81a
--- /dev/null
+++ b/Chapter12PracSpreadsheetToText.py
@@ -0,0 +1,19 @@
+#! usr/bin/env python3
+
+# Chapter 12 Practice
+# Spreadsheet to Text - Takes each column of data and creates a text file
+# with that data.
+
+import openpyxl
+
+wb = openpyxl.load_workbook('produceSales.xlsx')
+sheet = wb.get_active_sheet()
+
+for columnNum in range(1, sheet.get_highest_column()):
+ spreadText = open('Column ' + str(columnNum) +'.txt', 'a')
+ for rowNum in range(2, sheet.get_highest_row()):
+ rowData = sheet.cell(row=rowNum, column=columnNum).value
+ spreadText.write(str(rowData) + '\n')
+ spreadText.close()
+
+