Workhorse function for processing nested list into DataFrame
(self, f: ReadCsvBuffer[str] | list, **kwds)
| 97 | _no_thousands_columns: set[int] |
| 98 | |
| 99 | def __init__(self, f: ReadCsvBuffer[str] | list, **kwds) -> None: |
| 100 | """ |
| 101 | Workhorse function for processing nested list into DataFrame |
| 102 | """ |
| 103 | super().__init__(kwds) |
| 104 | |
| 105 | self.data: Iterator[list[str]] | list[list[Scalar]] = [] |
| 106 | self.buf: list = [] |
| 107 | self.pos = 0 |
| 108 | self.line_pos = 0 |
| 109 | |
| 110 | self.skiprows = kwds["skiprows"] |
| 111 | |
| 112 | if callable(self.skiprows): |
| 113 | self.skipfunc = self.skiprows |
| 114 | else: |
| 115 | self.skipfunc = lambda x: x in self.skiprows |
| 116 | |
| 117 | self.skipfooter = _validate_skipfooter_arg(kwds["skipfooter"]) |
| 118 | self.delimiter = kwds["delimiter"] |
| 119 | |
| 120 | self.quotechar = kwds["quotechar"] |
| 121 | if isinstance(self.quotechar, str): |
| 122 | self.quotechar = str(self.quotechar) |
| 123 | |
| 124 | self.escapechar = kwds["escapechar"] |
| 125 | self.doublequote = kwds["doublequote"] |
| 126 | self.skipinitialspace = kwds["skipinitialspace"] |
| 127 | self.lineterminator = kwds["lineterminator"] |
| 128 | self.quoting = kwds["quoting"] |
| 129 | self.skip_blank_lines = kwds["skip_blank_lines"] |
| 130 | |
| 131 | # Passed from read_excel |
| 132 | self.has_index_names = kwds.get("has_index_names", False) |
| 133 | |
| 134 | self.thousands = kwds["thousands"] |
| 135 | self.decimal = kwds["decimal"] |
| 136 | |
| 137 | self.comment = kwds["comment"] |
| 138 | |
| 139 | # Set self.data to something that can read lines. |
| 140 | if isinstance(f, list): |
| 141 | # read_excel: f is a nested list, can contain non-str |
| 142 | self.data = f |
| 143 | else: |
| 144 | assert hasattr(f, "readline") |
| 145 | # yields list of str |
| 146 | self.data = self._make_reader(f) |
| 147 | |
| 148 | # Get columns in two steps: infer from data, then |
| 149 | # infer column indices from self.usecols if it is specified. |
| 150 | self._col_indices: list[int] | None = None |
| 151 | columns: list[list[Scalar | None]] |
| 152 | ( |
| 153 | columns, |
| 154 | self.num_original_columns, |
| 155 | self.unnamed_cols, |
| 156 | ) = self._infer_columns() |
no test coverage detected