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 7956777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:05:41+00:00 2026-06-04T04:05:41+00:00

I have an Excel workbook which I want to scroll through the contents of

  • 0

I have an Excel workbook which I want to scroll through the contents of the first column and write each unique value to a new workbook i.e. no duplicates.

This code, without checking for duplicates, works fine:

def get_data_from_sheet(sheet_index, start_row, end_row, count):
for row in range(start_row, end_row):
    cell = sheet.cell(row,0)
    count = count+1 
    if row != start_row:
        sheet1.write(count,0,cell.value)
return count

However when I try to add a condition to check for duplicates, nothing is written to the Excel file:

from django.utils.encoding import smart_str

def get_data_from_sheet(sheet_index, start_row, end_row, count):
for row in range(start_row, end_row):
    cell = sheet.cell(row,0)
    count = count+1 
    if row != start_row:
        list.append(smart_str(cell.value))
        if smart_str(cell.value) not in list:
            sheet1.write(count,0,cell.value)
return count

Which puzzles me, because the list contains the values i.e.:

enter image description here

So what am I doing wrong? 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-06-04T04:05:42+00:00Added an answer on June 4, 2026 at 4:05 am

    By calling this:

        list.append(smart_str(cell.value))
    

    before this:

        if smart_str(cell.value) not in list:
    

    You are sure that the test will be always False, as you append the value to the list just before testing it is not in it. You have an issue with the logic here.

    NB: avoid calling your variables with built-in types, call your list object lst or anything else making sense but don’t use list as a variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an excel workbook which needs to query data from an HTTP server.
I have an Excel Workbook which has some VSTO-based c# code. Given a known
I have an Excel workbook that I want to use as a template. It
I have an Excel-Workbook. In this workbook a new sheet is created via VBA.
I have a VBA publishing macro in Excel which generates a published workbook based
I have an excel workbook in which there is data from multiple text files.
I have a java code which fetches data from excel document. I want to
I have an Excel 2007 workbook which I am using to connect to a
I want to accomplish the following task. I have an web application through which
I have report.xlsx file which contains data from 2 other excel workbook which got

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.