@@ -408,7 +408,8 @@ def load(name, records, antennas, attributes=None, recharges=None,
408
408
409
409
410
410
def _read_network (user , records_path , attributes_path , read_function ,
411
- antennas_path = None , warnings = True , extension = ".csv" ):
411
+ antennas_path = None , warnings = True , extension = ".csv" ,
412
+ ** kwargs ):
412
413
connections = {}
413
414
correspondents = Counter ([r .correspondent_id for r in user .records ])
414
415
@@ -419,7 +420,7 @@ def _read_network(user, records_path, attributes_path, read_function,
419
420
connections [c_id ] = read_function (c_id , records_path ,
420
421
antennas_path , attributes_path ,
421
422
describe = False , network = False ,
422
- warnings = False )
423
+ warnings = False , ** kwargs )
423
424
else :
424
425
connections [c_id ] = None
425
426
@@ -479,7 +480,7 @@ def _load_recharges(path):
479
480
480
481
def read_csv (user_id , records_path , antennas_path = None , attributes_path = None ,
481
482
recharges_path = None , network = False , duration_format = 'seconds' ,
482
- describe = True , warnings = True , errors = False ):
483
+ describe = True , warnings = True , errors = False , drop_duplicates = False ):
483
484
"""
484
485
Load user records from a CSV file.
485
486
@@ -521,6 +522,10 @@ def read_csv(user_id, records_path, antennas_path=None, attributes_path=None,
521
522
If errors is True, returns a tuple (user, errors), where user is the
522
523
user object and errors are the records which could not be loaded.
523
524
525
+ drop_duplicates : boolean
526
+ If drop_duplicates, remove “duplicated records“ (same correspondants,
527
+ direction, date and time). Not activated by default.
528
+
524
529
525
530
Examples
526
531
--------
@@ -574,12 +579,14 @@ def read_csv(user_id, records_path, antennas_path=None, attributes_path=None,
574
579
575
580
user , bad_records = load (user_id , records , antennas , attributes , recharges ,
576
581
antennas_path , attributes_path , recharges_path ,
577
- describe = False , warnings = warnings )
582
+ describe = False , warnings = warnings ,
583
+ drop_duplicates = drop_duplicates )
578
584
579
585
# Loads the network
580
586
if network is True :
581
587
user .network = _read_network (user , records_path , attributes_path ,
582
- read_csv , antennas_path , warnings )
588
+ read_csv , antennas_path , warnings ,
589
+ drop_duplicates = drop_duplicates )
583
590
user .recompute_missing_neighbors ()
584
591
585
592
if describe :
0 commit comments