Python Forum
File Content comparison-csv
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File Content comparison-csv
#2
You won't go very far if you don't try to understand what is going on in the code.

The code above use sets, on which you can perform intersection and difference.

There is one trick in the code above, you can construct a set from a sequence, and an open file object being a sequence of all the lines, set(file) creates a set with every line in the file. However, these lines include or not the \n delimiter so reading them directly in the set without sanitizing them first can be dangerous. The output file is also created with the hope that the line delimiters are all there already.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
File Content comparison-csv - by JP_ROMANO - Jun-14-2017, 04:50 PM
RE: File Content comparison-csv - by Ofnuts - Jun-15-2017, 09:30 AM
RE: File Content comparison-csv - by JP_ROMANO - Jun-15-2017, 12:48 PM
RE: File Content comparison-csv - by JP_ROMANO - Jun-15-2017, 02:37 PM
RE: File Content comparison-csv - by nilamo - Jun-15-2017, 04:50 PM
RE: File Content comparison-csv - by JP_ROMANO - Jun-15-2017, 05:34 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020