ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The concept seems simple, just combine dev#s that have devTypes, but the solution eludes me.
Below is the monstrosity that I tried and it fails miserably. In the below example 'regressionList' corresponds to the above sample input.
Code:
def writeTest(regressionList):
# extract all cellNames
cellsToPlace = []
for test in regressionList:
if test[0] not in cellsToPlace:
cellsToPlace.append(test[0])
for cell in cellsToPlace:
devTypes = []
for test in regressionList:
if test[0] == cell and len(test) > 1:
devTypes.append(test[2])
print(cell,devTypes)
Use a defaultdict where the key is the first column and the default value is an empty list.
I'm sure there's something obvious to you in this advice but I have no idea how this moves me toward my goal. I do not know how to build a defaultdict from the input.
Not an interview question - but the concern is understood. It is probably clear that I would never qualify for even an entry level python programming position. I work for a semiconductor design company and 95% of my work consist of SKILL programming for pcell development.
Python was needed for this particular project to extract data from an excel file. SKILL has no built in functions for handling excel spreadsheets so I decided to use python to extract the required data from the excel file and write the result to a csv file.
Modified # column 2 to place the colon after the input.
original: new_rows[original_row[0]][1] += ":" + original_row[2]
change: new_rows[original_row[0]][1] += original_row[2] + ":"
The final result still has a trailing ":" that is not needed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.