Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a project where I am going through a list of emails and making a change to a database. The issue is that I won't be able to do it all at once(i need to break this up into multiple runs). But I also don't want to overlap emails I already processed.

The emails are filled in from a CSV. I want to loop through each email and if the process was successful want to mark a column with "X". This way I can have my program make sure not to use emails with "x"s next to them. Then export it to the same file so I won't have to make any changes the next time I run.

I am having trouble with the logic though.

changes = ['[email protected]', '[email protected]']

if data['emails'] in changes:

data = pd.read_csv('data.csv')

###process goes here and exports list of processed emails in changes

changes = ['[email protected]', '[email protected]']
if data['emails'] in changes:
    data['processed'] = "x"
data.to_csv('data.csv')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.4k views
Welcome To Ask or Share your Answers For Others

1 Answer

Put the CSV in a data frame and add a “marking” column to the data frame. Add a 1 or an x to the correct row in the data frame anytime the email is used. You can use the index to know how to mark the x. Ie you are in column Email index 5, you then would append an X in column “indicator” index 5.

pseudo code

x = 0
for x in range (y):
    df.[“Email”].iloc[x]
    df.insert(x, “indicator”, “x”

When you’re done export to a csv and overwrite the pervious file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...