May-06-2019, 05:16 PM
Having huge no of records in original requirement.
Here a small peace of sample data.
For the year 2012 and 2013 data is not there for Employee 282 and for the year 2011 and 2013 data is not there for Employee 296 , so i need to add 0 or NULL .
Got some google info, but it is hardcode value, where as mine is a dynamic one.
https://stackoverflow.com/questions/2144...ain-length]
Also this is different from
https://python-forum.io/Thread-Split-Lis...rom-Pyodbc
as here we are splitting data not adding zeros or null.
For better understanding having single/ same set of data to work around.
Here a small peace of sample data.
results = [ (Decimal('28000.0000'), 2010, 272), (Decimal('308000.0000'), 2011, 272), (Decimal('582000.0000'), 2012, 272), (Decimal('387000.0000'), 2013, 272), (Decimal('367000.0000'), 2010, 281), (Decimal('3037000.0000'), 2011, 281), (Decimal('4822000.0000'), 2012, 281), (Decimal('2936000.0000'), 2013, 281), (Decimal('637000.0000'), 2010, 282), (Decimal('3440000.0000'), 2011, 282), (Decimal('478000.0000'), 2010, 296), (Decimal('1209000.0000'), 2012, 296) ] #Desired output CalendarYear = [2010,2011,2012,2013] Salesamount = [[28000.00,308000.00,582000.00,387000.00],[367000.00,3037000.00,4822000.00,2936000.00],[637000.00,3440000.00,0,0],[478000.00,0,1209000.00,0]] Employee = [272,281,282,296]How to add zeros or null to Salesamount list by forming sublist as here each sublist should have 4 records.
For the year 2012 and 2013 data is not there for Employee 282 and for the year 2011 and 2013 data is not there for Employee 296 , so i need to add 0 or NULL .
Got some google info, but it is hardcode value, where as mine is a dynamic one.
https://stackoverflow.com/questions/2144...ain-length]
Also this is different from
https://python-forum.io/Thread-Split-Lis...rom-Pyodbc
as here we are splitting data not adding zeros or null.
For better understanding having single/ same set of data to work around.