I have a file which has a table with large number of rows and columns.
column 2 contain RF, SVM,NV
column 3 contain SMOT,SVM,NV
COLUMN4 contain chi2,fs_based_rd,withour
Has these values which repeats on time. so there will be many rows which will contain RF
, smote
, chi2
i want all the rows with similar values to save at a place to calculate mean for all similar values.
My file is like this:
I want a resulting file like this:
Assuming that the columns in your file are space-separated, you could use Python's CSV reader .
For example:
import csv
result = []
with open('file.csv') as csv_file:
csv_content = csv.reader(csv_file, delimiter=' ')
for csv_row in csv_content:
if csv_row[1:4] == ['RF', 'smote', 'chi2']:
result.append(csv_row)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.