-1

I have a CSV file with the following format:

"SHA-1","MD5","CRC32","FileName","FileSize","ProductCode","OpSystemCode"

Basically what I'm looking to do in Python 2.x is read the file and if within the filename column, any files exist with a specified file extension from a list, the data from the MD5 hash column is parsed out into a text document.

So my pseudo code is looking like this:

list = [.doc,.xls,.ppt]

with open(new.csv) as new_f:
    with open(x.csv) as old_f:
        x = f.readlines()
        if list in x:
            # *copy out the value from the MD5 value column to new.csv*

I just don't know how to extract the MD5 hash.

Any suggestions?

4

2 に答える 2

0

MD5-Hash 用に 1 つのリストを作成し、ファイル名用に 1 つのリストを作成します。リストがファイル名リストの項目にある場合は、インデックスを保存して MD5 リストに使用します (テーブルがあるため、インデックスは同じ)

于 2012-10-26T12:31:07.693 に答える
0

特定された解決策:-

import csv

results = []
filetypes = ['jpg','bmp','jpeg','mov','mp4','avi','wmv','wav','tif','gif','png']
reader = csv.reader(open('c:\users\me\Desktop\x.csv'))
for extension in filetypes:
    for line in reader:  # iterate over the lines in the csv
        if extension in line[3]:
            print line[1] + "\t" + line[3]
于 2012-10-26T12:43:56.167 に答える