-
Notifications
You must be signed in to change notification settings - Fork 0
/
B_necessity_check.py
673 lines (562 loc) · 33.7 KB
/
B_necessity_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
# ********************************
# * 全国住户生活状况调查季报 *
# * 问卷B审核公式(必要性) *
# * 2015年08月26日 *
# ********************************
import pandas as pd
import datetime
import myLogging as mylogger
from typing import Any
# Year = datetime.datetime.now().year
# Month = datetime.datetime.now().month
B_necessity_result = pd.DataFrame()
def insert_to_pd(data):
global B_necessity_result
B_necessity_result = B_necessity_result.append(data, ignore_index=True)
def read_csv(path):
with open(path, 'r') as f:
file = pd.read_csv(f, header=0)
return file
def Table(table, code):
t = table[code]
# print("tabledata:",t)
if t.empty == False:
if pd.isnull(t.values[0]) == True:
return 0
if type(t.values[0]) == type("str"):
# print("字符串类型:",type(t.values[0]))
return int(t.values[0])
return t.values[0]
else:
return 0
# B表必要性审核
def B_necessity_check(tableB,zhuhu,zhuzhai,xiaoqu,result_table):
mylogger.logger.debug("B_necessity_check init..")
B,M = 92,993
E = 95
global B_necessity_result
B_necessity_result.drop( B_necessity_result.index, inplace=True)
B_necessity_result = result_table
xiaoqu["VID"] = xiaoqu["VID"].apply(str)
xiaoqu["VID"] = xiaoqu["VID"].apply(lambda x: x.strip())
# B1部分 住房基本情况
#B1.1 期末现住房基本情况
#超界错误。b101 - b116重写,0825lw
#B101 ?: "B101填报错误"
#if tableB['B101']:
# result = open(r'D:\研一\审核程序\src\审核结果输出\B_necessity_CheckResult.txt', 'w')
for row in tableB.iterrows():
single_row = row[1]
#zhuzhai对应M1,zhuhu对应M2
family_sid = single_row['SID']
one_zhuhu = zhuhu[zhuhu['HHID'] == family_sid]
one_zhuzhai = zhuzhai[zhuzhai['HID'] == family_sid[:-2]]
# Year = Table(single_row, "YEAR")
Year = int(float(single_row['YEAR']))
# print(Year,single_row['YEAR'])
scode = single_row['SCODE']
qu_vid = family_sid[0:15]
qu = xiaoqu[xiaoqu['VID'] == qu_vid]
townname = qu['TOWNNAME'].values[0]
vname = qu['VNAME'].values[0]
# qu = xiaoqu[xiaoqu['vID'] == qu_vid]
# townname = qu['townName'].values[0]
# vname = qu['vName'].values[0]
dict = {'year':str(single_row['YEAR']),'sid':family_sid,'scode':scode,'核实说明':None,'townname':townname,'vname':vname}
# result.write(single_row['SID']+":")
# if pd.isnull(single_row['B101']) == False:
if Table(one_zhuhu,'HHSTATUS') == 2:
continue
B101 = single_row['B101']
if B101 != 0:
# print('aaaa')
if B101 < 1 or B101 > 4:
dict['code'] = "B101={}".format(B101)
dict['核实内容'] = "住宅类型越界,请填写(1-4)"
insert_to_pd(dict)
if single_row['B102'] < 1 or single_row['B102'] > 8:
dict['code'] = "B101={},B102={}".format(B101,single_row['B102'])
dict['核实内容'] = "本住宅的建筑样式越界,请填写(1-8)"
insert_to_pd(dict)
if single_row['B103'] < 1 or single_row['B103'] > 5:
dict['code'] = "B101={},B103={}".format(B101,single_row['B103'])
dict['核实内容'] = "主要建筑材料越界,请填写(1-5)"
insert_to_pd(dict)
if single_row['B104'] < 1 or single_row['B104'] > 11:
dict['code'] = "B101={},B104={}".format(B101, single_row['B104'])
dict['核实内容'] = "房屋来源越界,请填写(1-11)"
insert_to_pd(dict)
if single_row['B105'] <= 0 or single_row['B105'] > 999:
dict['code'] = "B101={},B105={}".format(B101, single_row['B105'])
dict['核实内容'] = "建筑面积填报越界,请核实"
insert_to_pd(dict)
if single_row['B106'] <1 or single_row['B106'] > 3:
dict['code'] = "B101={},B106={}".format(B101, single_row['B106'])
dict['核实内容'] = "住宅外道路路面情况越界,请填写(1-3)"
insert_to_pd(dict)
if single_row['B107'] < 1 or single_row['B107'] > 3:
dict['code'] = "B101={},B107={}".format(B101, single_row['B107'])
dict['核实内容'] = "住宅内是否有管道自来水越界,请填写(1-3)"
insert_to_pd(dict)
if single_row['B108'] < 1 or single_row['B108'] > 7:
dict['code'] = "B101={},B108={}".format(B101, single_row['B108'])
dict['核实内容'] = "主要饮用水来源越界,请填写(1-7)"
insert_to_pd(dict)
if single_row['B109'] < 1 or single_row['B109'] > 4:
dict['code'] = "B101={},B109={}".format(B101, single_row['B109'])
dict['核实内容'] = "获取饮用水存在的困难越界,请填写(1-4)"
insert_to_pd(dict)
if single_row['B110'] < 1 or single_row['B110'] > 5:
dict['code'] = "B101={},B110={}".format(B101, single_row['B110'])
dict['核实内容'] = "饮用水处理措施越界,请填写(1-5)"
insert_to_pd(dict)
if single_row['B111'] < 1 or single_row['B111'] > 5:
dict['code'] = "B101={},B111={}".format(B101, single_row['B111'])
dict['核实内容'] = "厕所类型越界,请填写(1-5)"
insert_to_pd(dict)
if single_row['B112'] < 1 or single_row['B112'] > 3:
dict['code'] = "B101={},B112={}".format(B101, single_row['B112'])
dict['核实内容'] = "厕所使用情况越界,请填写(1-3)"
insert_to_pd(dict)
if single_row['B113'] < 1 or single_row['B113'] > 4:
dict['code'] = "B101={},B113={}".format(B101, single_row['B113'])
dict['核实内容'] = "洗澡设施越界,请填写(1-4)"
insert_to_pd(dict)
if single_row['B114'] < 1 or single_row['B114'] > 3:
dict['code'] = "B101={},B114={}".format(B101, single_row['B114'])
dict['核实内容'] = "主要取暖设备状况越界,请填写(1-3)"
insert_to_pd(dict)
if single_row['B115'] < 1 or single_row['B115'] > 11:
dict['code'] = "B101={},B115={}".format(B101, single_row['B115'])
dict['核实内容'] = "主要取暖能源状况越界,请填写(1-11)"
insert_to_pd(dict)
if single_row['B116'] < 1 or single_row['B116'] > 11:
dict['code'] = "B101={},B116={}".format(B101, single_row['B116'])
dict['核实内容'] = "主要灶用能源状况越界,请填写(1-11)"
insert_to_pd(dict)
#逻辑审核
if single_row['B102'] == 8:
if single_row['B103'] == 1 or single_row['B103'] == 2:
dict['code'] = "B101={},B102={},B03={}".format(B101, single_row['B102'],single_row['B103'])
dict['核实内容'] = "居住空间样式为其他,建筑材料不应为钢混或砖混结构"
insert_to_pd(dict)
if single_row['B107'] == 1 and single_row['B109'] == 1:
dict['code'] = "B101={},B107={},B109={}".format(B101, single_row['B107'],single_row['B109'])
dict['核实内容'] = "有自来水,单次取水时间却超过半小时?"
insert_to_pd(dict)
#跳转审核
if 8 >= single_row['B104'] >= 3:
sum = single_row['B117']+single_row['B118']+single_row['B119']+single_row['B120']+single_row['B121']+single_row['B122']+single_row['B123']+single_row['B124']+single_row['B125']+single_row['B126']
if sum <= 0:
dict['code'] = "sum(B117-B126)={}".format(sum)
dict['核实内容'] = "现住房为自有房者应填写B117-B126"
insert_to_pd(dict)
# if single_row['B104'] == 1 or single_row['B104'] == 2:
# if tableM['M101'] <= 1 and tableM['M205'] == 4:
# if single_row['B127'] <= 0:
# result.write('现住房为租赁房者应填写B127')
if single_row['B104'] == 1 or single_row['B104'] == 2:
if Table(one_zhuzhai, 'M101') <= 1 and Table(one_zhuhu,'M205') == 4:
if tableB['B127'] <= 0:
dict['code'] = "B104={},M101={},M205={},B127={}".format(single_row['B104'], Table(one_zhuzhai, 'M101'), Table(one_zhuhu,'M205'),single_row['B127'])
dict['核实内容'] = "现住房为租赁房者应填写B127"
insert_to_pd(dict)
# print('ok')
# df = tableM[single_row['SID'][:-2] == tableM['SID']]
# for index, Modi in df.iterrows():
# if single_row['SID'][:-2] == Modi['SID']:
# if pd.isnull(single_row['B101']) == False:
# 住家保姆、帮工或者集体居住户审核
if B101 != 0:
if Table(one_zhuhu,'M205') == 4:
# value = single_row.apply(lambda : x['B117']+x['B118'], axis=1)
# sum = 0
# for i in range(117, 151):
# s = "%s%s" % ('B', str(i))
# sum += single_row[s]
# print(sum)
if single_row['B117'] + single_row['B118'] + single_row['B119'] + single_row['B120'] + single_row['B121'] + single_row['B122'] \
+ single_row['B123'] + single_row['B124'] + single_row['B125'] + single_row['B126'] + single_row['B127'] + single_row[
'B128'] \
+ single_row['B129'] + single_row['B130'] + single_row['B131'] + single_row['B132'] + single_row['B133'] + single_row[
'B134'] \
+ single_row['B135'] + single_row['B136'] + single_row['B137'] + single_row['B138'] + single_row['B139'] + single_row[
'B140'] \
+ single_row['B141'] + single_row['B142'] + single_row['B143'] + single_row['B144'] + single_row['B145'] + single_row[
'B146'] \
+ single_row['B147'] + single_row['B148'] + single_row['B149'] + single_row['B150'] > 0:
dict['核实内容'] = '住家保姆、帮工,不用填B117-B150'
insert_to_pd(dict)
if B101 != 4:
dict['code'] = "B101={}".format(B101)
dict['核实内容'] = '住家保姆、帮工,B101要填4'
insert_to_pd(dict)
if single_row['B104'] != 10:
dict['code'] = "B101={}".format(B101)
dict['核实内容'] = '住家保姆、帮工,B101要填10'
insert_to_pd(dict)
if single_row['B112'] != 2:
dict['code'] = "B112={}".format(single_row['B112'])
dict['核实内容'] = '住家保姆、帮工,B112要填2'
insert_to_pd(dict)
# print(single_row['SID'], " ", Table(one_zhuzhai, 'M101'))
if Table(one_zhuzhai,'M101') == 1 and B101 != 0:
# B1.2 自有现住房情况
if 8 >= single_row['B104'] >= 3:
if single_row['B118'] < 0.5 or single_row['B118'] >= 999:
dict['code'] = "B118={}".format(single_row['B118'])
dict['核实内容'] = 'B118自有现住房市场价'
insert_to_pd(dict)
if single_row['B119'] < 100 or single_row['B119'] >= 9999:
dict['code'] = "B119={}".format(single_row['B119'])
dict['核实内容'] = 'B119同类住房的市场价月租金越界'
insert_to_pd(dict)
if single_row['B120'] < 1949 or single_row['B120'] > Year:
dict['code'] = "B120={}".format(single_row['B120'])
dict['核实内容'] = 'B120现住房购(建)房时间越界'
insert_to_pd(dict)
if single_row['B121'] < 0.5 or single_row['B121'] >= 999:
dict['code'] = "B121={}".format(single_row['B118'])
dict['核实内容'] = 'B121购(建)房总金额越界'
insert_to_pd(dict)
if single_row['B122'] != 0:
if single_row['B122'] < 0.1 or single_row['B122'] >= 999:
dict['code'] = "B122={}".format(single_row['B122'])
dict['核实内容'] = 'B122购(建)房时借贷总额(不含利息)越界'
insert_to_pd(dict)
if single_row['B125'] < 1 or single_row['B125'] > 30:
dict['code'] = "B125={}".format(single_row['B125'])
dict['核实内容'] = 'B125借贷款还款总年限越界'
insert_to_pd(dict)
if pd.isnull(single_row['B123']) == False:
if single_row['B123'] < 1 or single_row['B123'] >= 999:
dict['code'] = "B123={}".format(single_row['B123'])
dict['核实内容'] = 'B123购(建)房按揭贷款越界'
insert_to_pd(dict)
if pd.isnull(single_row['B124']) == False:
if single_row['B124'] < 0.01 or single_row['B124'] >= 99:
dict['code'] = "B124={}".format(single_row['B124'])
dict['核实内容'] = 'B124购(建)房时借贷款总利息越界'
insert_to_pd(dict)
if pd.isnull(single_row['B125']) == False:
if single_row['B126'] != 1 and single_row['B126'] != 2:
dict['code'] = "B126={}".format(single_row['B126'])
dict['核实内容'] = 'B126现在是否还在还款越界'
insert_to_pd(dict)
if single_row['B121'] < single_row['B122']:
dict['code'] = "B121={},B122={}".format(single_row['B121'],single_row['B122'])
dict['核实内容'] = '借贷款总额不应大于购(建)房总金额'
insert_to_pd(dict)
if single_row['B122'] < single_row['B123']:
dict['code'] = "B122={},B123={}".format(single_row['B122'], single_row['B123'])
dict['核实内容'] = '按揭贷款不应大于借贷款总额'
insert_to_pd(dict)
if single_row['B122'] == 0:
if pd.isnull(single_row['B124']) == False:
dict['code'] = "B122={},B124={}".format(single_row['B122'], single_row['B124'])
dict['核实内容'] = '没借贷款不应有利息'
insert_to_pd(dict)
if pd.isnull(single_row['B125']) == False:
dict['code'] = "B122={},B125={}".format(single_row['B122'], single_row['B125'])
dict['核实内容'] = '没借贷款不应填还款总年限'
insert_to_pd(dict)
if pd.isnull(single_row['B126']) == False:
dict['code'] = "B122={},B126={}".format(single_row['B122'], single_row['B126'])
dict['核实内容'] = '没借贷款不应填写B126'
insert_to_pd(dict)
# B1.3 期内拥有其它房屋情况
data = single_row['B128']
if data > 0:
if data < 5 or data > 999:
dict['code'] = "B128={}".format(data)
dict['核实内容'] = 'B128出租住房建筑面积填报越界'
insert_to_pd(dict)
if single_row['B129'] < 0.3 or single_row['B129'] >= 999:
dict['code'] = "B128={},B129={}".format(data,single_row['B129'])
dict['核实内容'] = 'B129出租住房市场价越界'
insert_to_pd(dict)
if single_row['B130'] < 100 or single_row['B130'] >= 9999:
dict['code'] = "B128={},B130={}".format(data,single_row['B130'])
dict['核实内容'] = 'B130出租住房月租金越界'
insert_to_pd(dict)
data = single_row['B131']
if data > 0:
if data < 1 or data > 999:
dict['code'] = "B131={}".format(single_row['B131'])
dict['核实内容'] = 'B131出租商用建筑物建筑面积填报越界'
insert_to_pd(dict)
if single_row['B132'] < 0.3 or single_row['B132'] >= 999:
dict['code'] = "B131={},B132={}".format(single_row['B131'], single_row['B132'])
dict['核实内容'] = 'B132出租商用建筑物市场价越界'
insert_to_pd(dict)
data = single_row['B134']
if data > 0:
if data < 1 or data > 999:
dict['code'] = "B134={}".format(single_row['B134'])
dict['核实内容'] = 'B134偶尔居住房建筑面积填报越界'
insert_to_pd(dict)
if single_row['B135'] < 0.3 or single_row['B135'] >= 999:
dict['code'] = "B134={},B135={}".format(single_row['B134'], single_row['B135'])
dict['核实内容'] = 'B135偶尔居住房市场价越界'
insert_to_pd(dict)
if single_row["B136"] > 0:
if single_row['B136'] < 1 or single_row['B136'] > 999:
dict['code'] = "B136={}".format(single_row['B136'])
dict['核实内容'] = 'B136空宅或其他用途住房建筑面积填报越界'
insert_to_pd(dict)
if single_row['B137'] < 0.3 or single_row['B137'] >= 999:
dict['code'] = "B136={},B137={}".format(single_row['B136'], single_row['B137'])
dict['核实内容'] = 'B137空宅或其他用途住房市场价越界'
insert_to_pd(dict)
# B1.4新购住房情况审核
if 7 >= single_row['B104'] >= 4 and single_row['B120'] == Year:
if single_row['B138'] < 5 or single_row['B138'] >= 999:
dict['code'] = "B138={}".format(single_row['B138'])
dict['核实内容'] = '新购住房建筑面积越界'
insert_to_pd(dict)
data = single_row['B140']
if data != 0:
if data < 1 or data >= 999:
dict['code'] = "B140={}".format(single_row['B140'])
dict['核实内容'] = '新购住房借贷款总额(不含利息)越界'
insert_to_pd(dict)
if single_row['B141'] < 1 or single_row['B141'] >= 999:
dict['code'] = "B140={},B141={}".format(data,single_row['B141'])
dict['核实内容'] = '新购住房按界揭贷款越'
insert_to_pd(dict)
if single_row['B142'] < 1 or single_row['B142'] >= 99:
dict['code'] = "B140={},B142={}".format(data,single_row['B142'])
dict['核实内容'] = '新购住房借贷款总利息越界'
insert_to_pd(dict)
if single_row['B143'] < 1 or single_row['B143'] > 30:
dict['code'] = "B140={},B143={}".format(data,single_row['B143'])
dict['核实内容'] = '新购住房借贷款还款总年限越界'
insert_to_pd(dict)
if single_row['B142'] / data < 0 or single_row['B142'] / data >= 0.15:
dict['code'] = "B140={},B142={}".format(data,single_row['B142'])
dict['核实内容'] = '贷款利率越界'
insert_to_pd(dict)
if single_row['B143'] < 3 or single_row['B143'] > 30:
dict['code'] = "B140={},B143={}".format(data, single_row['B143'])
dict['核实内容'] = '还款年限越界'
insert_to_pd(dict)
if single_row['B139'] <= data:
dict['code'] = "B140={},B139={}".format(data, single_row['B139'])
dict['核实内容'] = '借贷款总额不应大于购(建)房总金额'
insert_to_pd(dict)
if data < single_row['B141']:
dict['code'] = "B140={},B141={}".format(data, single_row['B141'])
dict['核实内容'] = '按揭贷款不应大于借贷款总额'
insert_to_pd(dict)
if data == 0:
if single_row['B142'] != 0:
dict['code'] = "B140={},B142={}".format(data, single_row['B142'])
dict['核实内容'] = '没借贷款不应有利息'
insert_to_pd(dict)
if single_row['B143'] != 0:
dict['code'] = "B140={},B143={}".format(data, single_row['B143'])
dict['核实内容'] = '没借贷款不应填还款总年限'
insert_to_pd(dict)
# B1.5 新住房情况审核
if single_row['B104'] == 3 and single_row['B120'] == Year:
if single_row['B144'] != 0:
if single_row['B144'] < 5 or single_row['B144'] >= 999:
dict['code'] = "B144={}".format(single_row['B144'])
dict['核实内容'] = '新住房建筑面积越界'
insert_to_pd(dict)
sum = single_row['B146'] + single_row['B147'] + single_row['B148'] + single_row['B149']
if single_row['B145'] != sum :
dict['code'] = "B145={},B146{}+B147{}+B148{}+B149{}={}".format(single_row['B145'], single_row['B146'],single_row['B147'],single_row['B148'],single_row['B149'],sum)
dict['核实内容'] = '建房资金来源不平'
insert_to_pd(dict)
# B1.6 期内住房大修或装修费用
if single_row['B150'] > 99:
dict['code'] = "B150={}".format(single_row['B150'])
dict['核实内容'] = '住房大修或装修费用越界'
insert_to_pd(dict)
# break
#B2部分 耐用消费品情况
# if single_row['B101']:
if pd.isnull(B101) == False:
# print('ccc')
if single_row['B201'] < 0 or single_row['B201'] > 3:
dict['code'] = "B201={}".format(single_row['B201'])
dict['核实内容'] = 'B201耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B202'] < 0 or single_row['B202'] > 3:
dict['code'] = "B202={}".format(single_row['B202'])
dict['核实内容'] = 'B202耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B203'] < 0 or single_row['B203'] > 5:
dict['code'] = "B203={}".format(single_row['B203'])
dict['核实内容'] = 'B203耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B204'] < 0 or single_row['B204'] > 5:
dict['code'] = "B204={}".format(single_row['B204'])
dict['核实内容'] = 'B204耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B205'] < 0 or single_row['B205'] > 5:
dict['code'] = "B205={}".format(single_row['B205'])
dict['核实内容'] = 'B205耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B206'] < 0 or single_row['B206'] > 5:
dict['code'] = "B206={}".format(single_row['B206'])
dict['核实内容'] = 'B206耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B207'] < 0 or single_row['B207'] > 5:
dict['code'] = "B207={}".format(single_row['B207'])
dict['核实内容'] = 'B207耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B208'] < 0 or single_row['B208'] > 10:
dict['code'] = "B208={}".format(single_row['B208'])
dict['核实内容'] = 'B208耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B209'] < 0 or single_row['B209'] > 7:
dict['code'] = "B209={}".format(single_row['B209'])
dict['核实内容'] = 'B209耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B210'] < 0 or single_row['B210'] > 3:
dict['code'] = "B210={}".format(single_row['B210'])
dict['核实内容'] = 'B210耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B211'] < 0 or single_row['B211'] > 5:
dict['code'] = "B211={}".format(single_row['B211'])
dict['核实内容'] = 'B211耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
#if single_row['B212'] < 0 or single_row['B212'] > 5:
# result.write('B212耐用消费品拥有量超界,请核实')
if single_row['B213'] < 0 or single_row['B213'] > 2:
dict['code'] = "B213={}".format(single_row['B213'])
dict['核实内容'] = 'B213耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B214'] < 0 or single_row['B214'] > 2:
dict['code'] = "B214={}".format(single_row['B214'])
dict['核实内容'] = 'B214耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B215'] < 0 or single_row['B215'] > 3:
dict['code'] = "B215={}".format(single_row['B215'])
dict['核实内容'] = 'B215耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B216'] < 0 or single_row['B216'] > 10:
dict['code'] = "B216={}".format(single_row['B216'])
dict['核实内容'] = 'B216耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B217'] < 0 or single_row['B217'] > 10:
dict['code'] = "B217={}".format(single_row['B217'])
dict['核实内容'] = 'B217耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B218'] < 0 or single_row['B218'] > 10:
dict['code'] = "B218={}".format(single_row['B218'])
dict['核实内容'] = 'B218耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B219'] < 0 or single_row['B219'] > 10:
dict['code'] = "B219={}".format(single_row['B219'])
dict['核实内容'] = 'B219耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
#if single_row['B220'] < 0 or single_row['B220'] > 5:
# result.write('B220耐用消费品拥有量超界,请核实')
if single_row['B221'] < 0 or single_row['B221'] > 5:
dict['code'] = "B221={}".format(single_row['B221'])
dict['核实内容'] = 'B221耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B222'] < 0 or single_row['B222'] > 5:
dict['code'] = "B222={}".format(single_row['B222'])
dict['核实内容'] = 'B222耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B223'] < 0 or single_row['B223'] > 5:
dict['code'] = "B223={}".format(single_row['B223'])
dict['核实内容'] = 'B223耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
#if single_row['B224'] < 0 or single_row['B224'] > 5:
# result.write('B224耐用消费品拥有量超界,请核实')
if single_row['B225'] < 0 or single_row['B225'] > 5:
dict['code'] = "B225={}".format(single_row['B225'])
dict['核实内容'] = 'B225耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B226'] < 0 or single_row['B226'] > 5:
dict['code'] = "B226={}".format(single_row['B226'])
dict['核实内容'] = 'B226耐用消费品拥有量超界,请核实'
insert_to_pd(dict)
if single_row['B208'] > single_row['B207']:
dict['code'] = "B207={},B208={}".format(single_row['B207'],single_row['B208'])
dict['核实内容'] = 'B208拥有量不应超过B207,请核实'
insert_to_pd(dict)
if single_row['B211'] > single_row['B210']:
dict['code'] = "B210={},B211={}".format(single_row['B210'], single_row['B211'])
dict['核实内容'] = 'B211拥有量不应超过B210,请核实'
insert_to_pd(dict)
if single_row['B217'] > single_row['B216']:
dict['code'] = "B216={},B217={}".format(single_row['B216'], single_row['B217'])
dict['核实内容'] = 'B217拥有量不应超过B216,请核实'
insert_to_pd(dict)
if single_row['B219'] > single_row['B218']:
dict['code'] = "B218={},B219={}".format(single_row['B218'], single_row['B219'])
dict['核实内容'] = 'B219拥有量不应超过B218,请核实'
insert_to_pd(dict)
#B3部分 补充资料2:现住房房屋状况
# if single_row['B101']:
if single_row['B238'] < 1 or single_row['B238'] > 4:
dict['code'] = "B238={}".format(single_row['B238'])
dict['核实内容'] = '住户现住房所处场地状况越界,请填写(1-4)'
insert_to_pd(dict)
if single_row['B239'] < 1 or single_row['B239'] > 4:
dict['code'] = "B239={}".format(single_row['B239'])
dict['核实内容'] = '住户现住房屋安全状况越界,请填写(1-4)'
insert_to_pd(dict)
if single_row['B240'] != 1 and single_row['B240'] != 2:
dict['code'] = "B240={}".format(single_row['B240'])
dict['核实内容'] = '住宅地面是否经常有泥土、沙土、畜禽粪便等脏东西越界,请填写(1-2)'
insert_to_pd(dict)
#B3部分 补充资料3:家庭或家庭成员合伙、参股或独立控股公司(企业)的经营情况 * lw 0905
# if single_row['B101']:
if single_row['B241'] != 1 and single_row['B241'] != 2:
dict['code'] = "B241={}".format(single_row['B241'])
dict['核实内容'] = '是否拥有独立控股的公司(企业)越界,请填写(1-2)'
insert_to_pd(dict)
if single_row['B243'] != 1 and single_row['B243'] != 2:
dict['code'] = "B243={}".format(single_row['B243'])
dict['核实内容'] = '是否拥有合伙或参股的公司(企业)越界,请填写(1-2)'
insert_to_pd(dict)
if single_row['B242'] > 0:
if single_row['B241'] != 1:
dict['code'] = "B241={},B242={}".format(single_row['B241'],single_row['B242'])
dict['核实内容'] = '有公司(企业)税后净利润,应有公司'
insert_to_pd(dict)
if single_row['B244'] > 0:
if single_row['B243'] != 1:
dict['code'] = "B243={},B244={}".format(single_row['B243'], single_row['B242'])
dict['核实内容'] = '有公司(企业)税后净利润,应有公司'
insert_to_pd(dict)
# print('done!')
return B_necessity_result
# 打开csv文件 返回DataFrame对象
def read_csv(path):
with open(path, 'r') as f:
df = pd.read_csv(f, header=0,low_memory=False)
col = colUpper(df.columns.values.tolist())
df = df.rename(columns=col)
return df
# 将所有列名换成大写
def colUpper(col):
dict = {}
for key in col:
value = key.upper()
# print(value)
dict[key] = value
return dict
if __name__ == "__main__":
B_path = "D:\研一\审核程序\src\输入文件夹\B310151.18.csv"
tableB = read_csv(B_path)
zhuhu_path = u"\研一\审核程序\src\输入文件夹\住户样本310151.18.csv"
zhuzhai_path = u"\研一\审核程序\src\输入文件夹\住宅名录310151.18.csv"
xiaoqu_path = u"D:\研一\项目\CheckProgram\Auditing\输入文件夹\小区名录310151.18.csv"
zhuzhai = read_csv(zhuzhai_path)
zhuhu = read_csv(zhuhu_path)
zhuzhai = read_csv(zhuzhai_path)
zhuhu = read_csv(zhuhu_path)
xiaoqu = read_csv(xiaoqu_path)
B_necessity_data = {'year': [], 'sid': [], 'scode': [], 'code': [], '核实内容': [],'核实说明':[], 'townname': [], 'vname': []}
B_necessity_result = pd.DataFrame(B_necessity_data)
B_necessity_result = B_necessity_result[['year', 'sid', 'scode', 'code', '核实内容','核实说明', 'townname', 'vname']]
B_necessity_check(tableB,zhuhu,zhuzhai,xiaoqu,B_necessity_result)
B_necessity_result.to_csv('B_necessity_result.csv',encoding='utf_8')