比较Regex输入和Excel电子表格,并打印/突出显示差异

发布于 2025-02-06 20:53:23 字数 777 浏览 0 评论 0原文

因此,我正在尝试创建一个程序来执行以下操作:

  1. 允许用户手动输入某些字母数字字符,其中包含一些正则表达式 - 例如^masdjoeufj0。|^waoifuwh2iw9。|^abcd130。
  2. 删除所有正则字符/定界符 - 。|^
  3. 将新的字母数字字符串打印出来 - 例如Masdjoeufj0 waoifuwh2iw9 abcd130
  4. 将Excel电子表格的内容加载到内存中,以进行比较,
  5. 以比较Alphanumeric String(在步骤3中)与Excel的内容进行比较电子表格
  6. 区别

打印/仅突出显示我对Python的新 到目前为止已经完成:

import re
import pandas as pd



str = input("Enter Regex : ")

pattern = r"['^\', '\\.|']"

str = re.sub(pattern, " ", str)

#str = str.split()

print (str, "\n", "\n")



df = pd.read_excel (r"C:\Users\...\...\...\Spreadsheet_Comparison.xlsx")

#print (df, "\n", "\n")

我不确定到目前为止我是否已经使用了正确的方法,因此在此要感谢任何帮助/指导。

我知道这可能不是编写此程序的最专业的方式,但我不需要它,我只需要一些基本的东西来完成这项工作,这很容易且直接遵循。

事先感谢您的所有帮助。

So I am trying to create a program to do the following:

  1. Allow a user to manually input some alphanumeric characters, with some regex included - e.g. ^MASDJOEUFJ0.|^WAOIFUWH2IW9.|^abcd130.
  2. Remove all regex characters/delimiters - ,.|^
  3. Print out the new alphanumeric string - e.g. MASDJOEUFJ0 WAOIFUWH2IW9 abcd130
  4. Load the contents of an Excel spreadsheet into memory, for comparison purposes
  5. Compare the alphanumeric string (in step 3) against the contents of the Excel spreadsheet
  6. Print/highlight only the differences

I am new to Python but using my previous programming experience I have created a program which will do up to step 4 but I am having issues trying to work out the last 2 steps - here is what I've done so far:

import re
import pandas as pd



str = input("Enter Regex : ")

pattern = r"['^\', '\\.|']"

str = re.sub(pattern, " ", str)

#str = str.split()

print (str, "\n", "\n")



df = pd.read_excel (r"C:\Users\...\...\...\Spreadsheet_Comparison.xlsx")

#print (df, "\n", "\n")

I am not sure if I have even used the correct approach so far or not, so any help/guidance here is appreciated.

I am aware that this might not be the most professional way of writing this program but I don't need it to be, I just need something basic that will do the job, and that is easy and straightforward to follow.

Thanks in advance for all the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文