こんな感じでパス設定すればOK
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import glob
import csv
if __name__ == '__main__':
filelist=[]
filelist.extend(glob.glob('./src/**/*.cpp', recursive=True))
filelist.extend(glob.glob('./src/**/*.c', recursive=True))
filelist.extend(glob.glob('./inc/**/*.hpp', recursive=True))
filelist.extend(glob.glob('./inc/**/*.h', recursive=True))
header_list=[]
header_list.append(["src","line","include"])
for filepath in filelist:
print(filepath)
with open(filepath, encoding='utf-8') as f:
for i, line in enumerate(f):
if '#include' in line:
line = line.replace('\n','')
header_list.append([filepath,str(i),line])
with open('./sample_writer.csv', 'w') as f:
writer = csv.writer(f)
writer.writerows(header_list)