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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:02:57+00:00 2026-06-12T02:02:57+00:00

I currently has an Excel file with one column for ItemID and one column

  • 0

I currently has an Excel file with one column for ItemID and one column for ItemName in this style:

ItemID, ItemName
2, Apple
4, Orange
5, Pear
6, Banana
15, Kiwi

I am open to converting this data in to whatever format would be easiest, but I need an explanation of how to go about that conversion.

I want to pass a list like this:
[‘Apple’, ‘Pear’, ‘Banana’]

And have it output a list like this:
[2,5,6]

I have looked at doing this with sqlite3 but I can’t find how to pass a whole list as input and I can’t find an easy way to convert my Excel file into some sort of .sql or .db file that sqlite3 could dig through. I really don’t care what sort of file (or even file-type item) I end up having to convert my Excel file into, I just want the look up process to be efficient.

EDIT:
In the actual case I’m working with there are about 8800 items. Also, each is unique such that ItemID is unique and ItemName is unique. That said, some item names are similar with just an extra word added on the end such as ‘Orange Small’ and ‘Orange Large’.

  • 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-12T02:02:58+00:00Added an answer on June 12, 2026 at 2:02 am

    This is basically the csv module version of @inspectorG4dget’s answer. First, save your file in csv format from Excel, producing something like this:

    ItemID, ItemName
    2, Apple
    4, Orange
    5, Pear
    6, Banana
    15, Kiwi
    

    Since you say that each ItemName is unique, we can use a dictionary to store the data. In python 2.7, and using a helper function like inspectorG4dget’s getIDs:

    import csv
    
    with open("itemids.csv","rb") as fp:
        reader = csv.reader(fp, skipinitialspace=True)
        fp.readline() # skip header
        name_to_id = {name: int(id) for id, name in reader}
    
    def getIDs(name_to_id, names):
        return [name_to_id[name] for name in names]
    

    We can build a dictionary and access it:

    >>> name_to_id
    {'Orange': 4, 'Kiwi': 15, 'Pear': 5, 'Apple': 2, 'Banana': 6}
    >>> getIDs(name_to_id, ["Apple", "Pear", "Banana"])
    [2, 5, 6]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently this is my python script ( TagGen ) which has one function: def
I currently have a CSV file which, when opened in Excel, has a total
My navigation panel currently has the following attributes: <div id='navpanel' style='float:left; width:300px; height:100%; overflow:hidden;
I'm building an app that currently has 3 ViewControllers. One of them is used
The web application I am working currently has an File import logic. The logic
currently, I am struggeling with the following: I have two Excel files. One files
Currently I monitoring a particular file with a simple shell one-liner: filesize=$(ls -lah somefile
So my iPhone application currently has a tabviewcontroller that populates the entire screen. The
The project currently has a UIviewController called Dashboard that acts as the main view
Our business currently has an online store and recently we've been offering free specials

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.