简体   繁体   中英

getting back feature extraction result in a csv

I have a csv dataset and had applied feature extraction such as wavelet, kurtosis so that later do machine learning. I am new to python and machine learning so not able to understand how to get back the feature extracted csv file.

Dataset

I am unable to get back the feature extracted csv file. what should I do?

This is the code which i wrote. I want that i get back features.csv as a result but it is not writing into it.

path = r"C:\Users\DELL PC\Desktop\Msc Project\MSc project\dataset"
for file in os.listdir(path):
    print(file)

lowfiles = files(os.path.join(path, r"Training data\LOW"))
highfiles = files(os.path.join(path, r"Training data\HIGH"))

mypath = 'Training-Data/'
csvfile = "Features/features.csv"

with open(csvfile, "a") as output:
    writer = csv.writer(output, lineterminator='\n')
    writer.writerow(names) 

    subfolder =  files[counter][1]
    tag = files[counter][1] 
    data_path = mypath + subfolder +'/'+files[counter][0]

Have a look at the pandas module. It provides a lot of I/O functions, powerful data processing, and much more.

Loading a CSV file from disk is as simple as:

import pandas as pd
df = pd.read_csv('path/to/infile.csv')

where df is a DataFrame , which is pandas' main data structure.

Writing a DataFrame to disk as a CSV file is also just one line:

df.to_csv('outfile.csv')

This link provides documentation to pandas I/O .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM