PID-server/yourls_api.py
def parse_csv(self, filename):
        """
        Parse CSV file into yourls-friendly csv.

        :param filename: required, string. URL to be shortened.
        :return: list. Parsed csv.
        """
        _ = self._check_kwargs(('url', 'keyword', 'title'))
        vals = {k: v for k, v in _}

        try:
            r = requests.get(filename)
            fp = r.content.decode().splitlines()
        except requests.exceptions.MissingSchema:
            r = None
            fp = open(filename, mode='r')

        csv_reader = csv.reader(fp)
        headers = [h.strip() for h in next(csv_reader)]
        ret_csv = []
        for line in csv_reader:
            parsed_line = []
            for k, v in vals.items():
                try:
                    parsed_line.append( line[headers.index(v)].strip() )
                except (ValueError, IndexError):
                    continue
            _ = self._check_kwargs(['uri_stem',])
            ret_csv.append((','.join(parsed_line) + '\n').replace(*[v for k, v in _], ''))

        if not r:
            fp.close()

        return ret_csv

        Parse CSV file into yourls-friendly csv.

        :param filename: required, string. URL to be shortened.
        :return: list. Parsed csv.
        
Parse CSV file into yourls-friendly csv.
Parse CSV file into yourls - friendly csv .
def parse_csv(self, filename):
        _ = self._check_kwargs(('url', 'keyword', 'title'))
        vals = {k: v for k, v in _}
        try:
            r = requests.get(filename)
            fp = r.content.decode().splitlines()
        except requests.exceptions.MissingSchema:
            r = None
            fp = open(filename, mode='r')
        csv_reader = csv.reader(fp)
        headers = [h.strip() for h in next(csv_reader)]
        ret_csv = []
        for line in csv_reader:
            parsed_line = []
            for k, v in vals.items():
                try:
                    parsed_line.append( line[headers.index(v)].strip() )
                except (ValueError, IndexError):
                    continue
            _ = self._check_kwargs(['uri_stem',])
            ret_csv.append((','.join(parsed_line) + '\n').replace(*[v for k, v in _], ''))
        if not r:
            fp.close()
        return ret_csv
def parse_csv ( self , filename ) : _ = self . _check_kwargs ( ( 'url' , 'keyword' , 'title' ) ) vals = { k : v for k , v in _ } try : r = requests . get ( filename ) fp = r . content . decode ( ) . splitlines ( ) except requests . exceptions . MissingSchema : r = None fp = open ( filename , mode = 'r' ) csv_reader = csv . reader ( fp ) headers = [ h . strip ( ) for h in next ( csv_reader ) ] ret_csv = [ ] for line in csv_reader : parsed_line = [ ] for k , v in vals . items ( ) : try : parsed_line . append ( line [ headers . index ( v ) ] . strip ( ) ) except ( ValueError , IndexError ) : continue _ = self . _check_kwargs ( [ 'uri_stem' , ] ) ret_csv . append ( ( ',' . join ( parsed_line ) + '\n' ) . replace ( * [ v for k , v in _ ] , '' ) ) if not r : fp . close ( ) return ret_csv
Parse CSV file into yourls-friendly csv.
Parse CSV file into yourls - friendly csv .
"""
        Parse CSV file into yourls-friendly csv.

        :param filename: required, string. URL to be shortened.
        :return: list. Parsed csv.
        """
list. Parsed csv.
list . Parsed csv .
self
filename
required, string. URL to be shortened.
required string . URL to be shortened .