почему мои данные строки json отсутствуют, такие как $ match, $ group при чтении данных через argparse - PullRequest
0 голосов
/ 13 июня 2018
parser = argparse.ArgumentParser()


parser.add_argument('-s', '--source', help='delimited list input', type=str)

parser.add_argument('-d', '--desc', help='delimited list input', type=str)

#into the command line

python main.py -s '''[{"type":"mongo","name":"prodmongo","query":"{ '$match': { 'event_code': 'SALE', 'properties.event_data.status': 'SUCCESS', 'properties.event_data.service': {'$in': ['a', 'b', 'c', 'd']}, 'properties.event_data.transaction_date': {'$lt': 'today_date', '$gte':'yesterday_date'} } }, { '$group': { '_id': '$properties.event_data.service', 'count': {'$sum': 1}, 'sale': {'$sum': '$properties.event_data.mrp'} } }, { '$project': { '_id': 0, 'service': '$_id', 'count': '$count', 'sale': '$sale' } }"},{"type":"sql","name":"prod_sql","query":"select service,count(*) as count,round(sum(mrp),2) as sale from demo where Transaction_Date>='{}' and Transaction_Date<'{}' AND Master_Distributor='PW' AND Service in ('a','b','c','d') AND STATUS='SUCCESS' and Apptype !='xyz' group by Service;"}]''' -d "hello"

sources = args.source
print(sources)

#output after reading through parser
[{"type":"mongo","name":"prodmongo","query":"{ : { event_code: SALE, properties.event_data.status: SUCCESS, properties.event_data.service: {: [a, b, c, d]}, properties.event_data.transaction_date: {: today_date, :yesterday_date} } }, { : { _id: .event_data.service, count: {: 1}, sale: {: .event_data.mrp} } }, { : { _id: 0, service: , count: , sale:  } }"},{"type":"sql","name":"prod_sql","query":"select service,count(*) as count,round(sum(mrp),2) as sale from demo where Transaction_Date>={} and Transaction_Date<{} AND Master_Distributor=PW AND Service in (a,b,c,d) AND STATUS=SUCCESS and Apptype !=xyz group by Service;"}]
...