0

I'm all new in Python but I have one interesting task. We have very big structural text. EXAMPLE:

'''

Writers 1.
Writer Dostoevsky, career: 1844-1849 (early career), 1849-1854 (exile to Siberia), 1854-1866 (prison, marriage).
Writer Pushkin, career: 1820-1822 (first publishing), 1836-1837 (duels and death).
Writers 2.
Writer Shakespeare, career: 1585-1588 (career beginning).
Writer Hemingway, career: 1913-1917 (high school), 1916-1917 (first publishing), 1818-1819 (World War I).
Writer Twain, career: 1883-1909 (Love of science and technology).

'''

We need to transform it excel spreadsheet to get clear view of information:

The Excel spreadsheet

How can i solve it? I tried to use regular expressions, but I guess it's not enough to get the spreadsheet, like in the picture.

Ron Rosenfeld
  • 53,870
  • 7
  • 28
  • 60
fatykhov8
  • 1
  • 1
  • Are you looking write to an Excel sheet? https://stackoverflow.com/questions/13437727/writing-to-an-excel-spreadsheet – Brydenr Dec 12 '19 at 18:39
  • Do you need to use Python? If this text is in Excel, it can readily be transformed using `Power Query` (available in Excel 2010+) – Ron Rosenfeld Dec 12 '19 at 19:37

1 Answers1

0

You will need to use the xlwt library. You can find that here

# Writing to an excel  
# sheet using Python 
import xlwt 
from xlwt import Workbook 

# Workbook is created 
wb = Workbook() 

# add_sheet is used to create sheet. 
sheet1 = wb.add_sheet('Sheet 1') 

sheet1.write(1, 0, 'ISBT DEHRADUN') 
sheet1.write(2, 0, 'SHASTRADHARA') 
sheet1.write(3, 0, 'CLEMEN TOWN') 
sheet1.write(4, 0, 'RAJPUR ROAD') 
sheet1.write(5, 0, 'CLOCK TOWER') 
sheet1.write(0, 1, 'ISBT DEHRADUN') 
sheet1.write(0, 2, 'SHASTRADHARA') 
sheet1.write(0, 3, 'CLEMEN TOWN') 
sheet1.write(0, 4, 'RAJPUR ROAD') 
sheet1.write(0, 5, 'CLOCK TOWER') 

wb.save('xlwt example.xls') 

sauce

Noah
  • 430
  • 1
  • 4
  • 21