I have been piled up in the following functions: Combine all files under a specific mask and delete duplicates based on two criteria: If the I do not currently have this test code properly (based on my previous question), but because it is using the dictionary, it is rewriting the previous data in which the same name But different lessons. I was just trying to use lists. How to filter the two conditions simultaneously? It is very much appreciated help Example name and TEXT equally holds up with the fourth largest column.
import glob, csv files = glob.glob ( "* .txt") fo = open ( "combined.csv" , "A") Author = csv.writer (fo, delimiter = '') Datum = [] files for f in nyt = set (): with open (f): csv The line reader (fi, Delimitr = ''): Crow = row [0] line [4] Nyt.add (Crow) that crow NAT: Dupl = [element element element if the element [0] == Row [0]] If Duplicate [0] [3] & lt; Line [3]: # Duplex [0] [3] & gt; Change the row to the row in line with the row. Row [3]: Other Continue: datum.append (line)
file1 Name 1 0.06 0.91 0.17 TEXT1 smthing smthing name2 0.46 0.42 0.02 TEXT1 smthing smthing name3 0.15 0.80 0.61 txt 1 smthing smthing file2 name 1 0.68 0.38 0.61 txt2 smthing smthing name 2 0.73 0.62 0.03 txt 2 smthing smthing name 3 0.84 0.81 0.60 txt2 sming smiling file 3 name 1 0.86 0.18 0.03 tx 1 smother smet name 2 0.04 0.12 0.75 txt 1 Smething Smming name 3 0.5 9 0.70 0.71 txt 1 I was thinking too much, add the quickest solution two values:
import Globe, csv files = glob.glob ( "* .txt ") A unique key for = open (" combined.csv "," a ") author = csv. For the row in Csv.reader (fi, delimiter = ''): The author (fo, delimiter = '') datum = {}: crow = line [0], row [4] for the form of open (F) ] If data in crow: if float (dawm [crow] [- 4]) & lt; Float (line [3]): datum [crow] = row [0:] Other: datum [crow] = row [0:]
No comments:
Post a Comment