Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import logging 

2 

3from sdc_etl_libs.sdc_dataframe.Dataframe import Dataframe 

4from sdc_etl_libs.sdc_dataframe.SDCDataframeEnums import SDCDFTypes 

5from sdc_etl_libs.sdc_file_helpers.SDCFile import SDCFile 

6 

7 

8class SDCAvroFile(SDCFile): 

9 type = None 

10 file_name = None 

11 file_path = None 

12 file_obj = None 

13 schema = None 

14 endpoint_schema = None 

15 df = None 

16 endpoint_type = None 

17 

18 def __init__(self, schema_, endpoint_schema_, file_name_, file_path_, file_obj_): 

19 super(SDCAvroFile, self).__init__(schema_, endpoint_schema_, file_name_, file_path_, file_obj_) 

20 

21 def get_file_size(self): 

22 pass 

23 

24 def get_file_as_dataframe(self): 

25 """ 

26 Converts a avro file object to a dataframe. 

27 

28 :return: A fully processed SDCDataframe. 

29 """ 

30 

31 df = Dataframe(None, self.schema) 

32 try: 

33 self.file_obj.seek(0) 

34 df.read_from_avro(self.file_obj) 

35 except Exception as e: 

36 logging.error(e) 

37 logging.error(f"Failed processing avro file.") 

38 

39 return df