diff options
Diffstat (limited to 'Chapter12PracSpreadsheetToText.py')
-rw-r--r-- | Chapter12PracSpreadsheetToText.py | 19 |
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() + + |