Python: Comparing specific columns in two csv files

Posted by coder999 on Stack Overflow See other posts from Stack Overflow or by coder999
Published on 2011-01-15T15:39:56Z Indexed on 2011/01/15 15:53 UTC
Read the original article Hit count: 173

Filed under:
|

Say that I have two CSV files (file1 and file2) with contents as shown below:

file1:

fred,43,Male,"23,45",blue,"1, bedrock avenue"

file2:

fred,39,Male,"23,45",blue,"1, bedrock avenue"

I would like to compare these two CSV records to see if columns 0,2,3,4, and 5 are the same. I don't care about column 1.

What's the most pythonic way of doing this?

EDIT:

Some example code would be appreciated.

© Stack Overflow or respective owner

Related posts about python

Related posts about csv