Return a pair RDD where key is taken from first column, remaining columns are named after their column id as string

def _load_text_csv_file(self, filename, separator=',', **kwargs):
        """Return a pair RDD where key is taken from first column, remaining columns are named after their column id as string"""
        rdd_input = self.sc.textFile(filename)

        def load_csv_record(line):
            input_stream = StringIO.StringIO(line)
            reader = csv.reader(input_stream, delimiter=',')
            # key in first column, remaining columns 1..n become dict key values
            payload = reader.next()
            key = payload[0]
            rest = payload[1:]
            # generate dict of "1": first value, "2": second value, ...
            d = {}
            for (cell,i) in izip(rest, range(1,1+len(rest))):
                d[str(i)] = cell
            # just in case, add "0": key
            d["0"] = key
            return (key, d)

        rdd_parsed = rdd_input.map(load_csv_record)
        return rdd_parsed