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

  • Home
  • SEARCH
  • 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 5979421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:39:24+00:00 2026-05-22T21:39:24+00:00

I am trying to write a script which will automate a copy/paste of employee

  • 0

I am trying to write a script which will automate a copy/paste of employee time sheets
from several files to one compiled file. Since they are time sheets with project codes some cells are left blank where an employee worked on a different project that day. Also the files have been converted from xlsx(2007) to .csv.xls which xlrd seems to open just fine.

I do know how to open and create a book object but my knowledge of this module is very limited so I thought maybe a general algorithm would be helpful:

import xlrd, xlwt

put all following in for or while loop to iterate through files:
book = xlrd.open_workbook('mybook.csv.xls')
extract data; store data for ouput
use for loop to iterate over data, output to final sheet
open next file, repeat process storing each output below the previous

I am looking for anything that will help me find the answers, not just code.
Any help would be appreciated. Thanks.

  • 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-05-22T21:39:25+00:00Added an answer on May 22, 2026 at 9:39 pm

    This might help … it reproduces your data as closely as possible (dates remain as dates, empty cells don’t become text cells with 0-length contents, booleans and error cells don’t become number cells).

    from xlrd import XL_CELL_EMPTY, XL_CELL_TEXT, XL_CELL_NUMBER,
        XL_CELL_DATE, XL_CELL_BOOLEAN, XL_CELL_ERROR, open_workbook
    from xlwt import Row, easyxf, Workbook
    
    method_for_type = {
        XL_CELL_TEXT:    Row.set_cell_text,
        XL_CELL_NUMBER:  Row.set_cell_number,
        XL_CELL_DATE:    Row.set_cell_number,
        XL_CELL_ERROR:   Row.set_cell_error,
        XL_CELL_BOOLEAN: Row.set_cell_boolean,
        }
    
    date_style = easyxf(num_format_str='yyyy-mm-dd')
    other_style = easyxf(num_format_str='General')
    
    def append_sheet(rsheet, wsheet, wrowx=0):
        for rrowx in xrange(rsheet.nrows):
            rrowvalues = rsheet.row_values(rrowx)
            wrow = wsheet.row(wrowx)
            for rcolx, rtype in enumerate(rsheet.row_types(rrowx)):
                if rtype == XL_CELL_EMPTY: continue
                wcolx = rcolx
                wmethod = method_for_type[rtype]
                wstyle = date_style if rtype == XL_CELL_DATE else other_style
                wmethod(wrow, wcolx, rrowvalues[rcolx], wstyle) 
            wrowx += 1
        return wrowx
    
    if __name__ == '__main__':
        import sys, xlrd, xlwt, glob
        rdpattern, wtfname = sys.argv[1:3]
        wtbook = Workbook()
        wtsheet = wtbook.add_sheet('guff')
        outrowx = 0
        for rdfname in glob.glob(rdpattern):
            rdbook = open_workbook(rdfname)
            rdsheet = rdbook.sheet_by_index(0)
            outrowx = append_sheet(rdsheet, wtsheet, outrowx)
            print outrowx
        wtbook.save(wtfname)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write T-sql script which will find open records for one
I am trying to write a ruby script which will look in a directory
I am trying to write an php twitter script which will be run by
I am trying to find a way to write a script which will check
I'm trying to write a powershell script which will execute sqlcmd.exe to run a
i'm trying to write a script which would process certain files. The data are
I'm trying to write a PowerShell script that will automate my IIS website deployments.
I am trying to write a threaded Python script which will iterate through a
I'm trying to write a shell script that, when run, will set some environment
I'm trying to write a Windows cmd script to perform several tasks in series.

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.