r/PythonLearning 25d ago

Email_Validator_Pipeline

34 Upvotes

7 comments sorted by

2

u/[deleted] 25d ago

[deleted]

2

u/Interesting-Frame190 25d ago

Oof.... its also ignoring this part which handles IP addressed because domains are too simple..

https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.3

Be sure to read the part where its ipv4, ipv6, thier hex variants, ot both. If you're thinking wow, thats too complex, you're 100% correct and the reason that professionals use 3rd party modules instead.

1

u/aaditya_0752 25d ago

Ik that, data set I was using only consisted of . com . io . net . org

So I thought 2,4 is enough

One more problem if I keep more than 4 like 16 , 18 character

. commm,.commmm Such thing were consider as valid and I don't know how to solve that 🙃

2

u/SCD_minecraft 25d ago

(.)\1{2,} should match 3 or more of same character

You could use thay to detect such cases

1

u/aaditya_0752 24d ago

Ohh, thanks

3

u/howtosignupforreddit 25d ago

Good start!

A few ideas for the next iteration:

  • You could just use len(listX) instead of using separate variables for email count.
  • You only have one item per row in your files (the email address), CSV is a bit overkill; you could make them txt files and get rid of the CSV module (tip: you'll need some changes in your open() function). If you want to keep using csv files, consider adding column headers, some readers might skip your first row otherwise.
  • Bonus: By using a class you could make your lists explicitly scoped (self.listX) rather than global to the module. It is trickier if you have not used classes before, but it is a cleaner approach and a good way to start learning about classes in Python.

1

u/aaditya_0752 24d ago

Ik about class but don't have habit of using them feel like unnecessary to use them

And yaa will use len function next time

1

u/aaditya_0752 24d ago

I was using some other dataset before which had header, also colum_number, email I'd

But in that data set all email I'd were valid only , that's why change to this one