pythonは、既存のcsvファイルデータに差を付けた後、新しいファイルとして保存し、ファイル名は変更されません.
5653 ワード
import pandas as pd
import numpy as np
import glob,os
import matplotlib.pylab as plt
from scipy import interpolate
save_wav_file = "E:\
ew_CO\\WAV" # csv
path = r'E:\
ew_CO\\wav_data'# csv
file = glob.glob(os.path.join(path, "*.csv"))
# print(file)
dl = []
for f in file:
dl.append(f)
def read( ):
for i in dl:
df = pd.read_csv(i)
ABP = df['values'].tolist()
m = 120
x=[i for i in range (1,len (ABP)+1)]
xi = np.linspace(1,len(ABP), m)
f = interpolate.interp1d(x, ABP,kind='slinear')
yi=f(xi)
wav_name=i.split("\\")[-1]
# f = open('E:\
ew_CO\\WAV', 'w', encoding='utf-8')
wav = pd.DataFrame({
"values": yi})
wav.to_csv(os.path.join(save_wav_file, wav_name), index=False)
read()