import numpy as np
def yesfloat(string):
""" True if given string is float else False"""
try:
return float(string)
except ValueError:
return False
data = []
with open('0 A.dat', 'r') as f:
d = f.readlines()
for i in d:
k = i.rstrip().split(",")
data.append([float(i) if yesfloat(i) else i for i in k])
data = np.array(data, dtype='O')
data
2条答案
按热度按时间mfpqipee1#
你可以用Pandas来读它们:
将pandas导入为pd
数据= pd.read_csv(文件名,文件名=',',skiprows=3)
6qqygrtg2#
我不知道这是否是你正在寻找的答案,但我尝试了你的数据,它返回了这个数组([列表(" %版本1.00"),列表(" %"]),列表(" %频率[Hz]\tTrc1_S21 [dB]\tTrc2_S21 [U]\tTrc3_S21 [U]\tTrc4_S21 [U"]),.,list([9998199819.981998,-22.89936928953151,0. 07161954135843378,-0.0618770495057106,-0.03606368601322174,']),list([9999099909.991,-22.91188769540125,0. 07151639513438152,-0.06464007496833801,-0.03059829212725163,']),list([10000000000.0,-22.92596306398167,0. 07140059761720122,-0.0669037401676178,-0.02493862248957157,''])],dtype = object)