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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:35:03+00:00 2026-06-17T12:35:03+00:00

I am parsing over 100 files that follow the same format. For example for

  • 0

I am parsing over 100 files that follow the same format. For example for one file, I have a dictionary consisting of two keys and multiple values in a list.

   temp2 = {
  '0.1995': ['X3:GATE', 'IN1', 'IN1', 'X7:GATE', 'X4:GATE', 'IN2', 'IN2', 'X8:GATE'],
  '0.399': ['X4:GATE', 'Y', 'Y', 'X3:GATE', 'Y', 'X8:SRC', 'X1:GATE', 'IN0', 'IN0', 'X5:GATE']

Here is the code that creates the temp2 dictionary:

#temp_delvt_list, temp_pin_list is from an external function
for delvt, pin in zip(temp_delvt_list, temp_pin_list):
                temp[delvt].append(pin) #dictionary with delvt and pin names for cell

            for line in SPFFile1:
#                   print line
                for delvt_keys,pin_values in temp.items():
#                   if re.match('[RC].*(?:i%s)' % '|'.join(pin_values), line): //couldn't get working
                    if re.search('(?i)' '|'.join(pin_values),line) and re.match('R',line):
                        #print delvt_keys
                        line_split = line.split(" ")
                        temp_list.append(delvt_keys)
                        temp_list.append(delvt_keys) #duplicated to create balanced list with temp_search_list
                        temp_search_list.append(line_split[1])
                        temp_search_list.append(line_split[2])
#                       print temp_list
#                       print temp_search_list
            SPFFile1.close()
            for d, p in zip(temp_list, temp_search_list):
                #print temp2[d]
            #   print re.sub(':SRC',':ISI',p)
                temp2[d].append(p) #dictionary with delvt and pin names for cell
#           print temp2

}

I am trying to search the values for each key and then for the key (0.1995) with no Y-values delete all values that appear for that key that also appear in the key (0.399) that has the Y values.The key values are not hardcoded and may change.

The output should be:

temp2 = {
  '0.1995': ['X3:GATE', 'IN1', 'IN1', 'X7:GATE', 'X4:GATE', 'IN2', 'IN2', 'X8:GATE'],
  '0.399': ['Y', 'Y','Y', 'X8:SRC', 'X1:GATE', 'IN0', 'IN0', 'X5:GATE']
}

Here is the code I have figured out so far:

        for test_d, test_p in temp2.items():
            if not re.search('Y', ' '.join(test_p)) :
                for x in test_p:
                    print x
            else:
                for y in test_p:
                    print y

Where I think I should replace the print statement with either lists that I compare either other to.

  • 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-17T12:35:04+00:00Added an answer on June 17, 2026 at 12:35 pm

    Probably you are looking for

    >>> temp2 = {
      '0.1995': ['X3:GATE', 'IN1', 'IN1', 'X7:GATE', 'X4:GATE', 'IN2', 'IN2', 'X8:GATE'],
      '0.399': ['X4:GATE', 'Y', 'Y', 'X3:GATE', 'Y', 'X8:SRC', 'X1:GATE', 'IN0', 'IN0', 'X5:GATE']
    }
    >>> _set = set(temp2['0.1995'])
    >>> temp2['0.399'] = [e for e in temp2['0.399'] if e not in _set]
    >>> import pprint
    >>> pp = PrettyPrinter(indent = 4)
    >>> pp.pprint(temp2)
    {   '0.1995': [   'X3:GATE',
                      'IN1',
                      'IN1',
                      'X7:GATE',
                      'X4:GATE',
                      'IN2',
                      'IN2',
                      'X8:GATE'],
        '0.399': ['Y', 'Y', 'Y', 'X8:SRC', 'X1:GATE', 'IN0', 'IN0', 'X5:GATE']}
    >>> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSV file that contains over 80,000 rows and 100 columns. I'm
I have a page that executes a long process, parsing over 6 million rows
I have a situation where I'm parsing csv file (100-150 lines at a time
I have two arrays built while parsing a text file. The first contains the
I have a problem parsing a XML file which contains special characters like ,
I have an XML document coming in over a socket that I need to
basically I am parsing a xml file and retrieving certain elements from that xml
Today I've looked over some C code that was parsing data from a text
I am parsing an XML file with the minidom parser, where I'm iterating over
I have a complicated programs which iterate over a bunch of input files does

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.