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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:34:03+00:00 2026-06-10T20:34:03+00:00

I have a text file exported out of a Excel document. Along its columns

  • 0

I have a text file exported out of a Excel document. Along its columns it lists each supplier and in the row below it is there respective pricing. At the end it will list minimum supplier and minimum price. Example:

Project: Name.
Supplier A, Supplier B, Supplier C, Lowest Price, Winning Supplier
600, 900, 650, 600, Supplier A 

Since I need to search through hundreds of excel documents and I thought it would be best to create text files of each and process the data in python.

I have gone through the python manual and I’m finding it difficult to get any results. The final result that I want is to be able to process numerous files from a single folder. My objective is to be able to list each supplier and search whether they were successful on each project and if they were not how much differential there was either in dollar terms or percentage from their price to the winning supplier.

Can anyone give some assistance on where to start to build this?

Greggy D

  • 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-10T20:34:04+00:00Added an answer on June 10, 2026 at 8:34 pm

    I would probably encapsulate the supplier data in a class:

    class Supplier(object):
        def __init__(self):
            self.projects = []  #winning projects
            self.bids = []      #how much this supplier bid, winning bid.
    

    Then I would parse each datafile individually as:

    from collections import defaultdict
    def parse_datafile(fname,output=None):
        if output is None:
           output = defaultdict(Supplier)
        with open(fname,r) as f:
           project = f.readline().split(':')[1].strip()
           suppliers = map(str.strip,f.readline().split(',')[:-2])
           bids = map(str.strip,f.readline().split(','))
           winner = bids[-1]
           win_amt = bids[-2]
    
           for s,b in zip(suppliers,bids):
               output[s].bids.append(int(b),int(win_amt))
           output[winner].projects.append(project)
        return output
    

    Now we can build up our dictionary:

     import glob
     from Collections import defaultdict
     d = defaultdict(Supplier)
     for fname in glob.iglob('*.txt'):
         d = parse_datafile(fname,output=d)
    

    And you can get information on that supplier by:

    print d['supplier A'].projects
    print [ float(bid)/winbid for bid,winbid in d['supplier A'].bids ]
    

    etc.

    Of course, there are libraries for parsing .xls files directly in python which might be more suitable than my hand-rolled parsing function. But I still think that the defaultdict which holds classes containing all the relevant info is probably you’re best bet here (irrespective of how you manage to parse the data).

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

Sidebar

Related Questions

I have exported data from a text file to an excel sheet, with the
I have a text file exported from a Foxpro (Dos-based) program, but this text
I have exported a CSV file from a database. Certain fields are longer text
I have exported excel 2007 document as CSV (separated by semicolon). I am using
I have text file with a row like this: SendersTimeSeriesIdentification: COMPANY_A/COMPANY_B/REF_7/20090505 I'd like to
I have text file with some stuff that i would like to put into
I have text file with something like first line line nr 2 line three
I have Text file that contains data separated with a comma , . How
I have text file, like FILED AS OF DATE: 20090209 DATE AS OF CHANGE:
I have text file with some text information and i need to split 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.