(
block,
part,
columns,
*,
reader,
header,
dtypes,
head,
colname,
full_columns,
enforce,
kwargs,
blocksize,
)
| 294 | |
| 295 | |
| 296 | def _read_csv( |
| 297 | block, |
| 298 | part, |
| 299 | columns, |
| 300 | *, |
| 301 | reader, |
| 302 | header, |
| 303 | dtypes, |
| 304 | head, |
| 305 | colname, |
| 306 | full_columns, |
| 307 | enforce, |
| 308 | kwargs, |
| 309 | blocksize, |
| 310 | ): |
| 311 | # Part will be a 3-element tuple |
| 312 | path, is_first, is_last = part |
| 313 | |
| 314 | # Construct `path_info` |
| 315 | if path is not None: |
| 316 | path_info = ( |
| 317 | colname, |
| 318 | path, |
| 319 | sorted(head[colname].cat.categories), |
| 320 | ) |
| 321 | else: |
| 322 | path_info = None |
| 323 | |
| 324 | # Deal with arguments that are special |
| 325 | # for the first block of each file |
| 326 | write_header = False |
| 327 | rest_kwargs = kwargs.copy() |
| 328 | if not is_first: |
| 329 | if rest_kwargs.get("names", None) is None: |
| 330 | write_header = True |
| 331 | rest_kwargs.pop("skiprows", None) |
| 332 | if rest_kwargs.get("header", 0) is not None: |
| 333 | rest_kwargs.pop("header", None) |
| 334 | if not is_last: |
| 335 | rest_kwargs.pop("skipfooter", None) |
| 336 | |
| 337 | # Deal with column projection |
| 338 | _columns = full_columns |
| 339 | project_after_read = False |
| 340 | if columns is not None and columns != full_columns: |
| 341 | if kwargs: |
| 342 | # To be safe, if any kwargs are defined, avoid |
| 343 | # changing `usecols` here. Instead, we can just |
| 344 | # select columns after the read |
| 345 | project_after_read = True |
| 346 | else: |
| 347 | _columns = columns |
| 348 | rest_kwargs["usecols"] = _columns |
| 349 | |
| 350 | # Call `pandas_read_text` |
| 351 | df = pandas_read_text( |
| 352 | reader, |
| 353 | block, |
nothing calls this directly
no test coverage detected