헤더가 '#'이고 쉼표로 구분 된 데이터가 포함 된 파일이 있습니다. 즉일부 헤더가있는 텍스트 파일을 히스토그램 배열로 바꿈
#blah
#blah
#blah
1, 2, 3, 4, 5, 6
7, 8, 9,10,11,12
...
#을 건너 뛰고 데이터를 배열 (열에 대한 히스토그램)로 바꿀 수 있기를 원합니다. 이 내용을 읽습니다.
filename = 'input.txt'
listin = []
for line in open(filename,'r'):
li=line.strip()
if not li.startswith("#"):
line = line.partition('#')[0]
#line = line.rstrip()
listin.append(line.split(','))
data = numpy.asarray(listin)
SubData=data[:,0]
hist,nbins = np.histogram(SubData)
Error:
TypeError: cannot perform reduce with flexible type