@@ -34,23 +34,23 @@ def find_largest_row(self, input: list) -> int:
3434 return largest
3535
3636
37- def find_largest_index (self , input : list ) -> int :
38- """Based on the largest row found, returns the index with the row
37+ def find_largest_char (self , input : list ) -> int :
38+ """Based on the largest row found, returns the char with the row
3939 from a given nested list.
4040
4141 :param input: nested list of varying length
4242 :type input: list
43- :return: index of largest row
43+ :return: char of largest row
4444 :rtype: int
4545 """
4646
4747 largest = self .find_largest_row (input )
4848
4949 for row in range (len (input )):
5050 if largest == len (input [row ]):
51- index = row
51+ char = row
5252
53- return index
53+ return char
5454
5555
5656 def read_csv_file (self ) -> list :
@@ -77,7 +77,7 @@ def read_csv_file(self) -> list:
7777 return self .data
7878
7979 def create_data_list (self , input : list ) -> Union [list , list ]:
80- """Creation of two data list based on destinction found at index 5
80+ """Creation of two data list based on destinction found at char 5
8181 for each row.
8282
8383 :param input: nested list of rows found
@@ -109,8 +109,8 @@ def uniform_data_list(self, input: list) -> list:
109109 :rtype: list
110110 """
111111
112- template_index = self .find_largest_index (input )
113- template_list = input [template_index ]
112+ template_char = self .find_largest_char (input )
113+ template_list = input [template_char ]
114114
115115 # Initialize an empty result list
116116 result_nested_list = []
@@ -197,7 +197,7 @@ def uniform_data_list_2(self, input: list) -> list:
197197 :return: updated nested list of same length
198198 :rtype: list
199199 """
200- template_idx = self .find_largest_index (input )
200+ template_idx = self .find_largest_char (input )
201201 template_list = input [template_idx ]
202202 template_markdown = []
203203
@@ -281,79 +281,142 @@ def process_str(self, _str: str) -> list:
281281
282282 def process_guar (self , _list : list ) -> list :
283283
284- # example_list = ['N', 'Y', 'NONE OF THE ABOVE', 'Y2535H', 'N000000N000000', '000000NN', '0000N']
284+ syntax = {
285+ 'N' : 'No' ,
286+ 'Y' : 'Yes' ,
287+ 'K' : 'Not provided' ,
288+ 'H' : 'Establish/Maintain a home' ,
289+ '000000' : 'Not provided'
290+ }
291+
292+ if len (_list ) == 11 :
293+ _list .insert (2 , ' ' .join (_list [2 :7 ]))
294+ del (_list [3 :8 ])
295+ elif len (_list ) == 5 :
296+ _list .insert (1 , 'Not provided' )
297+ _list .insert (2 , 'Not provided' )
298+ elif len (_list ) == 4 :
299+ _list .insert (1 , 'Not provided' )
300+ _list .insert (2 , 'Not provided' )
301+ if len (_list [- 1 ]) > 13 :
302+ val = _list [- 1 ]
303+ _list .insert (- 1 , val [:8 ])
304+ _list [- 1 ] = val [8 :]
305+
306+ if len (_list [3 ]) == 5 :
307+ _list [3 ] += 'K'
308+ elif len (_list [3 ]) == 19 :
309+ _list [3 ] += 'K'
310+ val = _list [3 ]
311+ del (_list [3 ])
312+ _list .insert (3 , val [:6 ])
313+ _list .insert (4 , val [6 :])
314+ elif len (_list [3 ]) == 20 :
315+ val = _list [3 ]
316+ del (_list [3 ])
317+ _list .insert (3 , val [:6 ])
318+ _list .insert (4 , val [6 :])
319+
320+ val = _list [3 ]
321+ del (_list [3 ])
322+ _list .insert (3 , val [0 ])
323+ _list .insert (4 , f'{ val [3 :5 ]} months; { val [1 :3 ]} years' )
324+ _list .insert (5 , val [5 ])
325+ _list .insert (6 , 'K' )
326+ _list .insert (7 , 'K' )
327+
328+ val = _list [8 ]
329+ del (_list [8 ])
330+ _list .insert (8 , f'{ val [0 ]} -- { val [1 :3 ]} /{ val [3 :7 ]} ' )
331+ _list .insert (9 , val [7 ])
285332
286- new_list = [ ]
287- # modified = [ ]
288- _str = ''
289- skip_idx = 0
290-
291- for i , item in enumerate ( _list ):
292- if item == 'NONE' :
293- _str += f' { _list [ i ] } { _list [ i + 1 ] } { _list [ i + 2 ] } { _list [ i + 3 ] } '
294- skip_idx = i + 3
295- new_list . append ( _str )
296- elif i > skip_idx or i == 0 :
297- new_list . append ( item )
298-
299- # print(new_list)
300- # given_index = 0
301-
302- # for item in example_list:
303- # if given_index < len(new_list) and len(new_list[given_index]) == len(item) or len(new_list[given_index]) == len(item)-1 :
304- # modified.append(new_list[given_index])
305- # given_index += 1
306- # else:
307- # modified.append('N/A')
308-
309- return new_list
333+ val = _list [ 10 ]
334+ final = _list [ 11 ]
335+ del ( _list [ 10 ])
336+ del ( _list [ 10 ])
337+ _list . insert ( 10 , val [ - 1 ])
338+ _list . insert ( 11 , final [ - 1 ])
339+ _list . insert ( 12 , val [ - 2 ])
340+ _list . insert ( 13 , val [: - 2 ])
341+ _list . insert ( 14 , f' { final [ 2 : 4 ] } months; { final [: 2 ] } years' )
342+
343+ _list . insert ( 2 , 'K' )
344+
345+
346+
347+
348+
349+
350+ for idx in range ( len (_list )) :
351+ for key , value in syntax . items ():
352+ if key == _list [ idx ]:
353+ _list [ idx ] = value
354+ break
355+
356+ return _list
310357
311358 def process_self (self , _list : list ) -> list :
312359
313- print (_list )
314-
315360 new_list = []
316361
317- if len (_list ) == 4 :
362+ if len (_list ) == 8 or len (_list ) == 9 :
363+ new_list .append (' ' .join (_list [1 :5 ]))
364+ del (_list [1 :5 ])
365+ elif len (_list [1 ]) == 23 :
366+ _list .insert (2 , _list [1 ][6 :])
367+ _list [1 ] = _list [1 ][:6 ]
368+ new_list .append (str (_list [0 ]).replace (' ' , 'Not provided' ))
369+ else :
318370 new_list .append (str (_list [0 ]).replace (' ' , 'Not provided' ))
371+
372+ if len (_list ) == 4 :
319373 if len (_list [1 ]) == 5 :
320374 new_list .append (str (_list [1 ][0 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
321375 new_list .append (f"{ _list [1 ][1 :3 ]} Years { _list [1 ][3 :5 ]} Months" )
322376 new_list .append ('Not provided' )
323377 elif len (_list [1 ]) == 6 :
324- new_list .append (str (_list [1 ][0 ]).replace ('Y' , 'Yes' ))
378+ new_list .append (str (_list [1 ][0 ]).replace ('Y' , 'Yes' ). replace ( 'N' , 'No' ) )
325379 new_list .append (f"{ _list [1 ][1 :3 ]} Years { _list [1 ][3 :5 ]} Months" )
326- new_list .append (str (_list [1 ][5 ]).replace ('H' , 'Establish/Maintain a home' ))
380+ new_list .append (str (_list [1 ][5 ]).replace ('C' , 'Go to College' ). replace ( ' H' , 'Establish/Maintain a home' ). replace ( 'W' , 'Work Assignment ' ))
327381 elif len (_list [1 ]) == 23 :
328382 new_list .append (str (_list [1 ][0 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
329- new_list .append (f"{ _list [1 ][1 :3 ]} Years { _list [2 ][3 :5 ]} Months" )
330- new_list .append (str (_list [1 ][5 ]).replace ('C' , 'Go to College' ))
383+ new_list .append (f"{ _list [1 ][1 :3 ]} Years { _list [1 ][3 :5 ]} Months" )
384+ new_list .append (str (_list [1 ][5 ]).replace ('C' , 'Go to College' ). replace ( 'H' , 'Establish/Maintain a home' ). replace ( 'W' , 'Work Assignment' ) )
331385 new_list .append (str (_list [1 ][6 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
332386 new_list .append (str (_list [1 ][7 :9 ]))
333- new_list .append (str ( _list [1 ][9 ]). replace ( 'Y' , 'Yes' ). replace ( 'N' , 'No' ) )
387+ new_list .append (f' { _list [1 ][9 ]} --acquired: { _list [ 1 ][ 14 : 16 ] } , { _list [ 1 ][ 10 : 14 ] } ' )
334388 new_list .append (str (_list [1 ][16 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
335-
336389
337- if len (len ( _list [2 ]) ) == 8 :
390+ if len (_list [2 ]) == 8 :
338391 new_list .append (str (_list [2 ][- 2 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
339392 new_list .append (str (_list [2 ][- 1 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
340393 elif len (_list [2 ]) == 14 :
341- new_list .append (str (_list [2 ][1 :7 ]).replace ('000000' , 'No' ))
342- new_list .append (str (_list [2 ][8 :14 ]).replace ('000000' , 'No' ))
343- new_list .append (str (_list [2 ][0 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
344- new_list .append (str (_list [2 ][7 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
394+ if _list [2 ][1 :7 ] == '000000' :
395+ new_list .append ('Not provided' )
396+ new_list .append ('Not provided' )
397+ new_list .append (str (_list [2 ][0 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
398+ new_list .append (f'{ _list [2 ][7 ]} --acquired: { _list [2 ][12 :]} , { _list [2 ][8 :12 ]} ' )
399+ elif _list [2 ][8 :] == '000000' :
400+ new_list .append ('Not provided' )
401+ new_list .append ('Not provided' )
402+ new_list .append (f'{ _list [2 ][0 ]} --acquired: { _list [2 ][5 :7 ]} , { _list [2 ][1 :5 ]} ' )
403+ new_list .append (str (_list [2 ][7 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
404+ else :
405+ new_list .append ('Not provided' )
406+ new_list .append ('Not provided' )
407+ new_list .append (f'{ _list [2 ][0 ]} --acquired: { _list [2 ][5 :7 ]} , { _list [2 ][1 :5 ]} ' )
408+ new_list .append (f'{ _list [2 ][7 ]} --acquired: { _list [2 ][12 :]} , { _list [2 ][8 :12 ]} ' )
345409 elif len (_list [2 ]) == 16 :
346410 new_list .append ('Not provided' )
347411 new_list .append (_list [2 ][0 :2 ])
348- new_list .append (f"{ _list [2 ][2 ]} --acquired: { _list [2 ][3 :7 ]} ,{ _list [2 ][7 :9 ]} " )
412+ new_list .append (f"{ _list [2 ][2 ]} --acquired: { _list [2 ][3 :7 ]} , { _list [2 ][7 :9 ]} " )
349413 new_list .append (str (_list [2 ][9 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
350414 elif len (_list [2 ]) == 17 :
351415 new_list .append (str (_list [2 ][0 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
352416 new_list .append (str (_list [2 ][1 :3 ]))
353- new_list .append (str ( _list [2 ][3 ]). replace ( 'Y' , 'Yes' ). replace ( 'N' , 'No' ) )
417+ new_list .append (f' { _list [2 ][3 ]} --acquired: { _list [ 2 ][ 8 : 10 ] } , { _list [ 2 ][ 4 : 8 ] } ' )
354418 new_list .append (str (_list [2 ][10 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
355419
356-
357420 if len (_list [3 ]) == 5 :
358421 new_list .append (str (_list [3 ][- 1 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
359422 new_list .append ("Not provided" )
@@ -362,7 +425,43 @@ def process_self(self, _list: list) -> list:
362425 new_list .append (str (_list [3 ][6 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
363426 new_list .append (str (_list [3 ][- 1 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
364427 new_list .append (str (_list [3 ][7 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
365- new_list .append (str (_list [3 ][8 ]).replace ('E' , 'Gainfully employed' ))
428+ new_list .append (str (_list [3 ][8 ]).replace ('E' , 'Gainfully employed' ). replace ( 'P' , 'Owns Property' ) )
366429 new_list .append (f"{ _list [3 ][9 :11 ]} Years { _list [3 ][11 :13 ]} Months" )
367430
431+ elif len (_list ) == 5 :
432+
433+ if len (_list [1 ]) == 5 :
434+ new_list .append (str (_list [1 ][0 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
435+ new_list .append (f"{ _list [1 ][1 :3 ]} Years { _list [1 ][3 :5 ]} Months" )
436+ new_list .append ('Not provided' )
437+ elif len (_list [1 ]) == 6 :
438+ new_list .append (str (_list [1 ][0 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
439+ new_list .append (f"{ _list [1 ][1 :3 ]} Years { _list [1 ][3 :5 ]} Months" )
440+ new_list .append (str (_list [1 ][5 ]).replace ('C' , 'Go to College' ).replace ('H' , 'Establish/Maintain a home' ).replace ('W' , 'Work Assignment' ))
441+
442+ if len (_list [2 ]) == 14 :
443+ new_list .append (str (_list [2 ][- 3 :]).replace ('000' , 'Not provided' ))
444+ new_list .append (str (_list [2 ][- 6 :- 3 ]).replace ('000' , 'Not provided' ))
445+ new_list .append (f'{ _list [2 ][0 ]} --acquired: { _list [2 ][5 :7 ]} , { _list [2 ][1 :5 ]} ' )
446+ new_list .append (str (_list [2 ][7 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
447+ elif len (_list [2 ]) == 16 :
448+ new_list .append ('Not provided' )
449+ new_list .append (str (_list [2 ][0 :2 ]))
450+ new_list .append (f'{ _list [2 ][2 ]} --acquired: { _list [2 ][7 :9 ]} , { _list [2 ][3 :7 ]} ' )
451+ new_list .append (str (_list [2 ][9 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
452+ elif len (_list [2 ]) == 17 :
453+ new_list .append (str (_list [2 ][0 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
454+ new_list .append (str (_list [2 ][1 :3 ]))
455+ new_list .append (f'{ _list [2 ][3 ]} --acquired: { _list [2 ][8 :10 ]} , { _list [2 ][4 :8 ]} ' )
456+ new_list .append (str (_list [2 ][10 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
457+
458+ if len (_list [3 ]) == 8 :
459+ new_list .append (str (_list [3 ][- 2 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
460+ new_list .append (str (_list [4 ][- 1 ]).replace ('Y' , 'Yes' ).replace ('N' , 'No' ))
461+ new_list .append (str (_list [3 ][:6 ]).replace ('000000' , 'No' ))
462+
463+ if len (_list [4 ]) == 5 :
464+ new_list .append (str (_list [3 ][- 1 ]).replace ('N' , 'Not provided' ))
465+ new_list .append (f"{ _list [4 ][:2 ]} Years { _list [4 ][2 :4 ]} Months" )
466+
368467 return new_list
0 commit comments