This commit is contained in:
parent
fc942497ce
commit
5f6983ee65
|
@ -317,11 +317,14 @@ class CNASViewSet(ModelViewSet):
|
|||
os.chdir(fulldir)
|
||||
CNAS.objects.all().delete()
|
||||
with zipfile.ZipFile(fullpath,'r') as zzz:
|
||||
print(zzz)
|
||||
zzz.extractall(fulldir)
|
||||
for root, dirs, files in os.walk(fulldir):
|
||||
for f in files:
|
||||
print(f)
|
||||
if f.endswith('.xls'):
|
||||
return Response('不支持旧xls格式', status = status.HTTP_400_BAD_REQUEST)
|
||||
print(f.encode('cp437').decode('gbk'), os.path.join(root,f))
|
||||
import_cnas(f.encode('cp437').decode('gbk'), os.path.join(root,f))
|
||||
return Response(status = status.HTTP_200_OK)
|
||||
|
||||
|
@ -386,8 +389,11 @@ def import_cma(filename, path):
|
|||
CMA.objects.bulk_create(datalist)
|
||||
|
||||
def import_cnas(filename, path):
|
||||
print(path)
|
||||
wb = load_workbook(path)
|
||||
|
||||
sheet = wb.get_sheet_by_name('检测能力范围')
|
||||
print(wb)
|
||||
datalist = []
|
||||
sszx = filename.replace('.xlsx','').replace('检测能力范围(含能源之星)-','')
|
||||
i = 3
|
||||
|
@ -417,6 +423,7 @@ def import_cnas(filename, path):
|
|||
data['sszx'] = sszx
|
||||
datalist.append(CNAS(**data))
|
||||
i = i + 1
|
||||
print(i,data)
|
||||
CNAS.objects.bulk_create(datalist)
|
||||
|
||||
def import_cma2(filename, path):
|
||||
|
|
Loading…
Reference in New Issue