I have a directory with 100s of files in the following format.
summary-0000016b9bf45ec8-AAAACCCC0286.json
summary-0000016b9bf47180-AAAACCCC0286.json
summary-0000016b9bf47746-AAAACCCC0286.json
summary-0000016b9bf47cd8-AAAACCCC0286.json
summary-0000016b9bf47f48-AAAACCCC0286.json
summary-0000016b9bf4818e-AAAACCCC0286.json
I need to extract the field after the summary and create a list of it. I am using an empty list and trying to append my output to it. Below is the code to create an empty list and append the fields I am extracting to it.
for files in dir:
if 'summary' in files and len(files.split('-')) > 1:
s_addr = []
s_addr.append(files.split('-')[1])
print (s_addr)
The output I am getting is a list for each item extracted as shown below:
['0000016b9bf31d5e']
['0000016b9bf45ec8']
['0000016b9bf1d8c4']
['0000016b9bf3c920']
['0000016b9bf2371f']
['0000016b9bf3d8ec']
['0000016b9bf11cb6']
Expected output is :
['0000016b9bf31d5e','0000016b9bf45ec8','0000016b9bf1d8c4','0000016b9bf3c920','0000016b9bf2371f','0000016b9bf3d8ec','0000016b9bf11cb6']
What am i doing wrong?