File size: 464 Bytes
34c2cc1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
docs = open("sample.pdf", "r")
doc_list = []


for file in docs:
    print('file - type : ', file.type)
    if file.type == 'text/plain':
        # file is .txt
        print("txt")
    elif file.type in ['application/octet-stream', 'application/pdf']:
        # file is .pdf
        print("pdf")
    elif file.type == 'text/csv':
        # file is .csv
        print("csv")
    elif file.type == 'application/json':
        # file is .json
        print("json")