cr-reunion: support multiple input file (#84828)
This commit is contained in:
parent
8eaa457c27
commit
91ec320b59
|
@ -104,16 +104,17 @@ def api_call(args, path, data=None, user_email=None, method='post'):
|
|||
|
||||
|
||||
def get_rows(args):
|
||||
with open(args.filepath) as csvfile:
|
||||
reader = csv.DictReader(csvfile, delimiter=',', quotechar='"')
|
||||
numline = 0
|
||||
for i, row in enumerate(reader):
|
||||
if i < args.start_line:
|
||||
continue
|
||||
if args.mode != 'full' and numline > args.sample_numlines:
|
||||
break
|
||||
numline += 1
|
||||
yield i, row
|
||||
for filepath in args.filepath:
|
||||
with open(filepath) as csvfile:
|
||||
reader = csv.DictReader(csvfile, delimiter=',', quotechar='"')
|
||||
numline = 0
|
||||
for i, row in enumerate(reader):
|
||||
if i < args.start_line:
|
||||
continue
|
||||
if args.mode != 'full' and numline > args.sample_numlines:
|
||||
break
|
||||
numline += 1
|
||||
yield i, row
|
||||
|
||||
|
||||
def import_data(args):
|
||||
|
@ -475,7 +476,7 @@ subparsers = parser.add_subparsers()
|
|||
|
||||
parser_import = subparsers.add_parser('import')
|
||||
parser_import.set_defaults(func=import_data)
|
||||
parser_import.add_argument('--filepath')
|
||||
parser_import.add_argument('--filepath', nargs='+')
|
||||
parser_import.add_argument('--mode', default='sample', choices=('sample', 'full'))
|
||||
parser_import.add_argument('--sample-numlines', default=100, type=int)
|
||||
parser_import.add_argument('--start-line', default=0, type=int)
|
||||
|
|
Loading…
Reference in New Issue