pricedb/csv.py
def parse_line(self, line: str) -> PriceModel:
        """ Parse a CSV line into a price element """
        line = line.rstrip()
        parts = line.split(',')

        result = PriceModel()

        # symbol
        result.symbol = self.translate_symbol(parts[0])

        # value
        result.value = Decimal(parts[1])

        # date
        date_str = parts[2]
        date_str = date_str.replace('"', '')
        date_parts = date_str.split('/')

        year_str = date_parts[2]
        month_str = date_parts[1]
        day_str = date_parts[0]

        logging.debug(f"parsing {date_parts} into date")
        result.datetime = datetime(int(year_str), int(month_str), int(day_str))

        return result
def parse_line(self, line: str) -> PriceModel:
        line = line.rstrip()
        parts = line.split(',')

        result = PriceModel()

        # symbol
        result.symbol = self.translate_symbol(parts[0])

        # value
        result.value = Decimal(parts[1])

        # date
        date_str = parts[2]
        date_str = date_str.replace('"', '')
        date_parts = date_str.split('/')

        year_str = date_parts[2]
        month_str = date_parts[1]
        day_str = date_parts[0]

        logging.debug(f"parsing {date_parts} into date")
        result.datetime = datetime(int(year_str), int(month_str), int(day_str))

        return result
def parse_line ( self , line : str ) -> PriceModel : line = line . rstrip ( ) parts = line . split ( ',' ) result = PriceModel ( ) # symbol result . symbol = self . translate_symbol ( parts [ 0 ] ) # value result . value = Decimal ( parts [ 1 ] ) # date date_str = parts [ 2 ] date_str = date_str . replace ( '"' , '' ) date_parts = date_str . split ( '/' ) year_str = date_parts [ 2 ] month_str = date_parts [ 1 ] day_str = date_parts [ 0 ] logging . debug ( f"parsing {date_parts} into date" ) result . datetime = datetime ( int ( year_str ) , int ( month_str ) , int ( day_str ) ) return result
Parse a CSV line into a price element
Parse a CSV line into a price element