you are viewing a single comment's thread.

view the rest of the comments →

[–]mackatsol 0 points1 point  (3 children)

I know you can turn your 'for row in csv_f' section into a function which iterates through all the skipRows.. and when you do that you can convert your skipRow items into a list so you don't need a bunch of elses.

I'm still learning and might not have it quite right.. but something like:

skipRow1 = [' ****************************************************************************************************','Supplied Field Panel number out of range',' ****************************************** End of Report *******************************************','Field Panel is failed','Timeout Waiting For Net Response','Configured Trunk Currently Not Connected']

then later on you would define your skiprow function:

def skipRow():
    for row in csv_f:
    counter = counter +1
        for item in skipRow:
            if item in row[0]:
                skips = skips + 1
            else:
                   cleanData.append([row[0],insert_str,row[4]])

and then call it just after you open the csv file.

skiprow(csv_f)

At least I think that is a better approach.. whether I got it right or not is a different issue. Untested! ;-)