| 161 | return self(csv_input).cache(delete_lineage=True) |
| 162 | |
| 163 | def csv_dict_reader( |
| 164 | self, |
| 165 | csv_file, |
| 166 | fieldnames=None, |
| 167 | restkey=None, |
| 168 | restval=None, |
| 169 | dialect="excel", |
| 170 | **kwds |
| 171 | ): |
| 172 | if isinstance(csv_file, str): |
| 173 | file_open = get_read_function(csv_file, self.disable_compression) |
| 174 | input_file = file_open(csv_file) |
| 175 | elif hasattr(csv_file, "next") or hasattr(csv_file, "__next__"): |
| 176 | input_file = csv_file |
| 177 | else: |
| 178 | raise ValueError( |
| 179 | "csv_file must be a file path or implement the iterator interface" |
| 180 | ) |
| 181 | |
| 182 | csv_input = csvapi.DictReader( |
| 183 | input_file, |
| 184 | fieldnames=fieldnames, |
| 185 | restkey=restkey, |
| 186 | restval=restval, |
| 187 | dialect=dialect, |
| 188 | **kwds |
| 189 | ) |
| 190 | return self(csv_input).cache(delete_lineage=True) |
| 191 | |
| 192 | def jsonl(self, jsonl_file): |
| 193 | """ |