CODE IN PYTHON PLEASE The objective is to create a code in Python that can extract the columns highlighted in blue (Column T and AB3) and output them to a .txt file. The code should be able to generate the text file with the columns that are highlighted in blue and store them on a separate folder. Below shows how the Test.xlsm file looks like as well as how the text file should look like when the code extracts and outputs it. Google drive to access Test.xlsm file: https://drive.google.com/drive/folders/16utzb5_h7yMCN8_13E_JqasfcpykZOYr?usp=sharing What my code outputs is shown in the picture (O1.png) What I would like for my code to output is the columns next to each other (Right Example.png) The current code is able to output Columns T and AB3 but I am not able to output them next to each other as shown above. We would also like for the code to be capable of storing the text file to a separate folder. Below is the code I have been working on. #package to read xlsm file import openpyxl #give full path to excel file here path = "Test.xlsm" #loading the excel sheet wb_obj = openpyxl.load_workbook(path) #loading the required sheet by name from excel sheet_obj = wb_obj["Correct-L"] #opening text file to write data. f = open("Correct_l.txt","w") #getting max number of rows sheet has, so we can loop through all rows num_row = sheet_obj.max_row #writing the first line to text file f.writelines("Band Group Number Time\n") #for loop to get data from first blue column #and saving every value that is not None to text file for i in range(3,num_row+1):       cell_obj = sheet_obj.cell(row=i, column=20)        if str(cell_obj.value) != "None":             f.writelines(str(cell_obj.value)+"\n") f.writelines("Band Group Number Time\n") #for loop to get data from second blue column #and saving every value that is not None to text file for i in range(3,num_row+1):      cell_obj = sheet_obj.cell(row=i, column=28)       if str(cell_obj.value) != "None":           f.writelines(str(cell_obj.value) + "\n")

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

CODE IN PYTHON PLEASE

The objective is to create a code in Python that can extract the columns highlighted in blue (Column T and AB3) and output them to a .txt file. The code should be able to generate the text file with the columns that are highlighted in blue and store them on a separate folder. Below shows how the Test.xlsm file looks like as well as how the text file should look like when the code extracts and outputs it.

Google drive to access Test.xlsm file: https://drive.google.com/drive/folders/16utzb5_h7yMCN8_13E_JqasfcpykZOYr?usp=sharing

What my code outputs is shown in the picture (O1.png)

What I would like for my code to output is the columns next to each other (Right Example.png)

The current code is able to output Columns T and AB3 but I am not able to output them next to each other as shown above. We would also like for the code to be capable of storing the text file to a separate folder. Below is the code I have been working on.

#package to read xlsm

file import openpyxl

#give full path to excel file here

path = "Test.xlsm"

#loading the excel sheet

wb_obj = openpyxl.load_workbook(path)

#loading the required sheet by name from excel

sheet_obj = wb_obj["Correct-L"]

#opening text file to write data.

f = open("Correct_l.txt","w")

#getting max number of rows sheet has, so we can loop through all rows

num_row = sheet_obj.max_row

#writing the first line to text file

f.writelines("Band Group Number Time\n")

#for loop to get data from first blue column

#and saving every value that is not None to text file

for i in range(3,num_row+1):

      cell_obj = sheet_obj.cell(row=i, column=20)

       if str(cell_obj.value) != "None":

            f.writelines(str(cell_obj.value)+"\n")

f.writelines("Band Group Number Time\n")

#for loop to get data from second blue column

#and saving every value that is not None to text file

for i in range(3,num_row+1):

     cell_obj = sheet_obj.cell(row=i, column=28)

      if str(cell_obj.value) != "None":

          f.writelines(str(cell_obj.value) + "\n")

*Correct-L.txt - Notepad
File
Edit
Format View Help
Band Group Number Time
1000
2000
3000
4452
5698
6521.00
7854.00
8000.00
9000.00
10000.00
11000.00
12000.00
13000.00
14000.00
15000.00
16000.00
17000.00
18000.00
19000.00
20000.00
21000.00
22000.00
23000.00
24000.00
25000.00
26000.00
27000.00
28000.00
29000.00
30000.00
31000.00
32000.00
33000.00
-380.00
Band Group Number Time
- 175.56
- 102.5
Transcribed Image Text:*Correct-L.txt - Notepad File Edit Format View Help Band Group Number Time 1000 2000 3000 4452 5698 6521.00 7854.00 8000.00 9000.00 10000.00 11000.00 12000.00 13000.00 14000.00 15000.00 16000.00 17000.00 18000.00 19000.00 20000.00 21000.00 22000.00 23000.00 24000.00 25000.00 26000.00 27000.00 28000.00 29000.00 30000.00 31000.00 32000.00 33000.00 -380.00 Band Group Number Time - 175.56 - 102.5
*Correct-L.txt - Notepad
File
Edit Format View Help
Band Group Number Time
- 175.56
1000
2000
- 102.5
3000
- 188.63
4452
-258.36
5698
-214.21
6521.00
246.00
7854.00
258.78
8000.00
271.56
9000.00
10000.00
11000.00
12000.00
13000.00
14000.00
15000.00
16000.00
17000.00
18000.00
19000.00
20000.00
21000.00
22000.00
23000.00
24000.00
25000.00
26000.00
27000.00
28000.00
29000.00
30000.00
31000.00
32000.00
33000.00
- 380.00
Transcribed Image Text:*Correct-L.txt - Notepad File Edit Format View Help Band Group Number Time - 175.56 1000 2000 - 102.5 3000 - 188.63 4452 -258.36 5698 -214.21 6521.00 246.00 7854.00 258.78 8000.00 271.56 9000.00 10000.00 11000.00 12000.00 13000.00 14000.00 15000.00 16000.00 17000.00 18000.00 19000.00 20000.00 21000.00 22000.00 23000.00 24000.00 25000.00 26000.00 27000.00 28000.00 29000.00 30000.00 31000.00 32000.00 33000.00 - 380.00
Expert Solution
steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Graphical User Interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education