MCPcopy Create free account
hub / github.com/dask/dask / _read_csv

Function _read_csv

dask/dataframe/io/csv.py:293–361  ·  view source on GitHub ↗
(
    block,
    part,
    columns,
    *,
    reader,
    header,
    dtypes,
    head,
    colname,
    full_columns,
    enforce,
    kwargs,
    blocksize,
)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

pandas_read_textFunction · 0.85
popMethod · 0.80
copyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected