Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8113581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:52:28+00:00 2026-06-06T02:52:28+00:00

import xlwt import xlrd import os.path import os print os.path.abspath(os.curdir) #Create workbook and worksheet

  • 0
 import xlwt
 import xlrd
 import os.path
 import os
 print os.path.abspath(os.curdir) 

#Create workbook and worksheet

wbk = xlwt.Workbook()
sheet = wbk.add_sheet('Data_1')#name of the sheet in which new data is there

row = 0

f = xlrd.open_workbook('Data_1.xls')#workbook from where data is extracted
g = xlrd.open_workbook('Data_2.xls')#workbook from where data is extracted

sheet1 = f.sheet_by_index(0)
sheet2 = g.sheet_by_index(0)

for i in xrange(16):
temp = sheet1.row_values(i)
print temp
col = 0
for element in temp:        
    sheet.write(i,col,element)
    col += 1
i += 1

for j in xrange(16):
temp = sheet2.row_values(j)
print temp
col = 4
for elements in temp:
    sheet.write(j,col.element)
    col +=1
j+=1
 wbk.save('DATA.xls') #excel sheet name when saved in the folder

On executing i am able to get the data on my console for the Data_1.xls but the moment it enters into second set of for loop it gives me error as follows:-

Traceback (most recent call last):
File "C:/Python26/combining2ExcelSheets.py", line 34, in <module>
sheet.write(j,col.element)
AttributeError: 'int' object has no attribute 'element'

One more thing the first column of my both the excel sheets(Data_1 and Data_2.xls) are same. If in my newly generated excel sheet I want to combine and organize my data according to the respective first column values. What should be my course of action so that desired sorted excel sheet is obtained?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:52:29+00:00Added an answer on June 6, 2026 at 2:52 am

    A typo!

    Replace:

    sheet.write(j,col.element)
    

    with

    sheet.write(j,col,element)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

import xlrd book = xlrd.open_workbook(File_1.xls) sheet = book.sheet_by_index(0) print sheet.row_values(0)[0] I am trying to
import xml.parsers.expat def start_element(name, attrs): print('Start element:', name, attrs) def end_element(name): print('End element:', name)
I'm using xlwt in python to create a Excel spreadsheet. You could interchange this
I am trying to use xlwt to create MS-Excel files from the contents of
import numpy as np M = np.matrix([ [-1,-2,-3], [-4,-5,-6] ]) print(M) How to multiply
import datetime, json x = {'alpha': {datetime.date.today(): 'abcde'}} print json.dumps(x) The above code fails
import sys print (sys.platform) print (2 ** 100) input('press Enter to exit') Suppose I
import java.util.*; public class HashingTest { // instance variables String name; int age; int
import sys try: raise xxx except str,e: print 1,e except: print 2,sys.exc_type,sys.exc_value In the
import numpy as np a = np.arange(1000000).reshape(1000,1000) print(a**2) With this code I get this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.