Load ASCII data stored in a comma-separated file. The returned array is a record array (if ``usemask=False``, see `recarray`) or a masked record array (if ``usemask=True``, see `ma.mrecords.MaskedRecords`). Parameters ---------- fname, kwargs : For a description of inp
(fname, **kwargs)
| 2510 | |
| 2511 | |
| 2512 | def recfromcsv(fname, **kwargs): |
| 2513 | """ |
| 2514 | Load ASCII data stored in a comma-separated file. |
| 2515 | |
| 2516 | The returned array is a record array (if ``usemask=False``, see |
| 2517 | `recarray`) or a masked record array (if ``usemask=True``, |
| 2518 | see `ma.mrecords.MaskedRecords`). |
| 2519 | |
| 2520 | Parameters |
| 2521 | ---------- |
| 2522 | fname, kwargs : For a description of input parameters, see `genfromtxt`. |
| 2523 | |
| 2524 | See Also |
| 2525 | -------- |
| 2526 | numpy.genfromtxt : generic function to load ASCII data. |
| 2527 | |
| 2528 | Notes |
| 2529 | ----- |
| 2530 | By default, `dtype` is None, which means that the data-type of the output |
| 2531 | array will be determined from the data. |
| 2532 | |
| 2533 | """ |
| 2534 | # Set default kwargs for genfromtxt as relevant to csv import. |
| 2535 | kwargs.setdefault("case_sensitive", "lower") |
| 2536 | kwargs.setdefault("names", True) |
| 2537 | kwargs.setdefault("delimiter", ",") |
| 2538 | kwargs.setdefault("dtype", None) |
| 2539 | output = genfromtxt(fname, **kwargs) |
| 2540 | |
| 2541 | usemask = kwargs.get("usemask", False) |
| 2542 | if usemask: |
| 2543 | from numpy.ma.mrecords import MaskedRecords |
| 2544 | output = output.view(MaskedRecords) |
| 2545 | else: |
| 2546 | output = output.view(np.recarray) |
| 2547 | return output |
nothing calls this directly
no test coverage detected