import pandas as pd
import numpy as np
import glob,os
import matplotlib.pylab as plt
from scipy import interpolate
save_wav_file = "E:\\new_CO\\WAV" # 存入csv 的文件地址
path = r'E:\\new_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:\\new_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()
python 对原有csv文件数据差值后,另存为新的文件,文件名保持不变。
最新推荐文章于 2023-04-16 00:15:07 发布