简体   繁体   English

Python 使用 Excel 自动执行任务的脚本

[英]Python script to automate tasks with Excel

First of all I am very sorry if this is a common questions, however I am still very new in the programming world, and cannot figure out the keywords for what I'm actually looking for.首先,如果这是一个常见问题,我感到非常抱歉,但是我在编程世界中仍然很新,无法找出我真正要寻找的关键字。

Basically I have an Excel spreadsheet with data Picture of Excel Sheet - For each identifier I have a 0 or a 1. My task is to copy the number in the identifier column, paste it into a webpage from my workplace and click a button to exclude the customer from billing.基本上我有一个 Excel 电子表格,其中包含 Excel 工作表的数据图片- 对于每个标识符,我都有一个 0 或 1。我的任务是复制标识符列中的数字,将其粘贴到我工作场所的网页中,然后单击一个按钮以排除客户从帐单。 Once I have done this, I will go back to the Excel spreadsheet and change the number from 0 to 1. Since there is a lot to go through, I thought this would be a fun project for me to start learning a basic script.完成此操作后,我会将 go 返回到 Excel 电子表格并将数字从 0 更改为 1。由于 go 有很多通过,我认为这对我来说是一个有趣的项目,可以开始学习基本脚本。 I did not make it very far though!不过我没走多远!

import pandas as pd 

Migreringer = pd.read_excel('Migreringer.xls')

ExludeBilling = Migreringer[["Exclude Billing", "Identifier"]]

IsExcludedBilling = Migreringer["Exclude Billing"] > 0

I was hoping that someone was able to give me a good idea as to how to move on from here, My idea is that it would check each row for the True/False statement from IsExcludedBilling, and then as a start copy the identifier if the statement is False and paste it into a word document or something similar to test this out?我希望有人能够给我一个关于如何从这里继续前进的好主意,我的想法是它会检查每一行是否来自 IsExcludedBilling 的 True/False 语句,然后作为开始复制标识符,如果陈述是错误的并将其粘贴到 word 文档或类似的东西中来测试它? I just cannot seem to figure out how to make Python go through each row and validate the statements, and then make it copy something from a different column in the same row to a different document?我似乎无法弄清楚如何通过每一行制作 Python go 并验证语句,然后让它从同一行的不同列复制一些东西到不同的文档?

I know from experience that I am more motivated in learning with a project in mind, so that is why I've chosen to start here.我从经验中知道,我在学习时更有动力考虑一个项目,所以这就是我选择从这里开始的原因。 Maybe I should take a couple of steps back before engaging with a project like this?在参与这样的项目之前,也许我应该退后几步?

do you wan this?你想要这个吗?

df = pd.DataFrame(
    {
        'Exclude Billing': [1,0,0,1,0],
        'Identifier': [ 41823,41835,41819,41798,41812],
    }
)
df_zero=df.loc[df['Exclude Billing']==0,:]
df_zero.to_csv('data_with_zero.csv',index=False)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM