-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbasics.io.genfromtxt.html
More file actions
1139 lines (939 loc) · 81 KB
/
basics.io.genfromtxt.html
File metadata and controls
1139 lines (939 loc) · 81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" data-content_root="../" data-theme="light">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Importing data with genfromtxt — NumPy v2.5.dev0 Manual</title>
<script data-cfasync="false">
document.documentElement.dataset.mode = localStorage.getItem("mode") || "light";
document.documentElement.dataset.theme = localStorage.getItem("theme") || "light";
</script>
<!--
this give us a css class that will be invisible only if js is disabled
-->
<noscript>
<style>
.pst-js-only { display: none !important; }
</style>
</noscript>
<!-- Loaded before other Sphinx assets -->
<link href="../_static/styles/theme.css?digest=8878045cc6db502f8baf" rel="stylesheet" />
<link href="../_static/styles/pydata-sphinx-theme.css?digest=8878045cc6db502f8baf" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=8f2a1f02" />
<link rel="stylesheet" type="text/css" href="../_static/graphviz.css?v=eafc0fe6" />
<link rel="stylesheet" type="text/css" href="../_static/plot_directive.css" />
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Vibur" />
<link rel="stylesheet" type="text/css" href="../_static/jupyterlite_sphinx.css?v=8ee2c72c" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx-design.min.css?v=95c83b7e" />
<link rel="stylesheet" type="text/css" href="../_static/numpy.css?v=e8edb4a7" />
<!-- So that users can add custom icons -->
<script src="../_static/scripts/fontawesome.js?digest=8878045cc6db502f8baf"></script>
<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
<script src="../_static/documentation_options.js?v=dcdc7152"></script>
<script src="../_static/doctools.js?v=888ff710"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/clipboard.min.js?v=a7894cd8"></script>
<script src="../_static/copybutton.js?v=30646c52"></script>
<script src="../_static/jupyterlite_sphinx.js?v=96e329c5"></script>
<script src="../_static/design-tabs.js?v=f930bc37"></script>
<script data-domain="numpy.org/doc/stable/" defer="defer" src="https://views.scientific-python.org/js/script.js"></script>
<script>DOCUMENTATION_OPTIONS.pagename = 'user/basics.io.genfromtxt';</script>
<script>
DOCUMENTATION_OPTIONS.theme_version = '0.16.1';
DOCUMENTATION_OPTIONS.theme_switcher_json_url = 'https://numpy.org/doc/_static/versions.json';
DOCUMENTATION_OPTIONS.theme_switcher_version_match = 'devdocs';
DOCUMENTATION_OPTIONS.show_version_warning_banner =
true;
</script>
<link rel="icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Data types" href="basics.types.html" />
<link rel="prev" title="I/O with NumPy" href="basics.io.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
<meta name="docsearch:version" content="2.5.dev0" />
<meta name="docbuild:last-update" content="Mar 12, 2026"/>
</head>
<body data-bs-spy="scroll" data-bs-target=".bd-toc-nav" data-offset="180" data-bs-root-margin="0px 0px -60%" data-default-mode="light">
<div id="pst-skip-link" class="skip-link d-print-none"><a href="#main-content">Skip to main content</a></div>
<div id="pst-scroll-pixel-helper"></div>
<button type="button" class="btn rounded-pill" id="pst-back-to-top">
<i class="fa-solid fa-arrow-up"></i>Back to top</button>
<dialog id="pst-search-dialog">
<form class="bd-search d-flex align-items-center"
action="../search.html"
method="get">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="search"
class="form-control"
name="q"
placeholder="Search the docs ..."
aria-label="Search the docs ..."
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"/>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
</form>
</dialog>
<div class="pst-async-banner-revealer d-none">
<aside id="bd-header-version-warning" class="d-none d-print-none" aria-label="Version warning"></aside>
</div>
<header class="bd-header navbar navbar-expand-lg bd-navbar d-print-none">
<div class="bd-header__inner bd-page-width">
<button class="pst-navbar-icon sidebar-toggle primary-toggle" aria-label="Site navigation">
<span class="fa-solid fa-bars"></span>
</button>
<div class="col-lg-3 navbar-header-items__start">
<div class="navbar-item">
<a class="navbar-brand logo" href="../index.html">
<img src="../_static/numpylogo.svg" class="logo__image only-light" alt="NumPy v2.5.dev0 Manual - Home"/>
<img src="../_static/numpylogo_dark.svg" class="logo__image only-dark pst-js-only" alt="NumPy v2.5.dev0 Manual - Home"/>
</a></div>
</div>
<div class="col-lg-9 navbar-header-items">
<div class="me-auto navbar-header-items__center">
<div class="navbar-item">
<nav>
<ul class="bd-navbar-elements navbar-nav">
<li class="nav-item current active">
<a class="nav-link nav-internal" href="index.html">
User Guide
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="../reference/index.html">
API reference
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="../building/index.html">
Building from source
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="../dev/index.html">
Development
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="../release.html">
Release notes
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-external" href="https://numpy.org/numpy-tutorials/">
Learn
</a>
</li>
<li class="nav-item dropdown">
<button class="btn dropdown-toggle nav-item" type="button"
data-bs-toggle="dropdown" aria-expanded="false"
aria-controls="pst-nav-more-links">
More
</button>
<ul id="pst-nav-more-links" class="dropdown-menu">
<li class=" ">
<a class="nav-link dropdown-item nav-external" href="https://numpy.org/neps">
NEPs
</a>
</li>
</ul>
</li>
</ul>
</nav></div>
</div>
<div class="navbar-header-items__end">
<div class="navbar-item">
<button class="btn btn-sm pst-navbar-icon search-button search-button__button pst-js-only" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass fa-lg"></i>
</button></div>
<div class="navbar-item">
<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button pst-js-only" aria-label="Color mode" data-bs-title="Color mode" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="theme-switch fa-solid fa-sun fa-lg" data-mode="light" title="Light"></i>
<i class="theme-switch fa-solid fa-moon fa-lg" data-mode="dark" title="Dark"></i>
<i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto" title="System Settings"></i>
</button></div>
<div class="navbar-item">
<div class="version-switcher__container dropdown pst-js-only">
<button id="pst-version-switcher-button-2"
type="button"
class="version-switcher__button btn btn-sm dropdown-toggle"
data-bs-toggle="dropdown"
aria-haspopup="listbox"
aria-controls="pst-version-switcher-list-2"
aria-label="Version switcher list"
>
Choose version <!-- this text may get changed later by javascript -->
<span class="caret"></span>
</button>
<div id="pst-version-switcher-list-2"
class="version-switcher__menu dropdown-menu list-group-flush py-0"
role="listbox" aria-labelledby="pst-version-switcher-button-2">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div></div>
<div class="navbar-item"><ul class="navbar-icon-links"
aria-label="Icon Links">
<li class="nav-item">
<a href="https://github.com/numpy/numpy" title="GitHub" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><i class="fa-brands fa-square-github fa-lg" aria-hidden="true"></i>
<span class="sr-only">GitHub</span></a>
</li>
</ul></div>
</div>
</div>
<button class="pst-navbar-icon sidebar-toggle secondary-toggle" aria-label="On this page">
<span class="fa-solid fa-outdent"></span>
</button>
</div>
</header>
<div class="bd-container">
<div class="bd-container__inner bd-page-width">
<dialog id="pst-primary-sidebar-modal"></dialog>
<div id="pst-primary-sidebar" class="bd-sidebar-primary bd-sidebar">
<div class="sidebar-header-items sidebar-primary__section">
<div class="sidebar-header-items__center">
<div class="navbar-item">
<nav>
<ul class="bd-navbar-elements navbar-nav">
<li class="nav-item current active">
<a class="nav-link nav-internal" href="index.html">
User Guide
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="../reference/index.html">
API reference
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="../building/index.html">
Building from source
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="../dev/index.html">
Development
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="../release.html">
Release notes
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-external" href="https://numpy.org/numpy-tutorials/">
Learn
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-external" href="https://numpy.org/neps">
NEPs
</a>
</li>
</ul>
</nav></div>
</div>
<div class="sidebar-header-items__end">
<div class="navbar-item">
<button class="btn btn-sm pst-navbar-icon search-button search-button__button pst-js-only" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass fa-lg"></i>
</button></div>
<div class="navbar-item">
<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button pst-js-only" aria-label="Color mode" data-bs-title="Color mode" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="theme-switch fa-solid fa-sun fa-lg" data-mode="light" title="Light"></i>
<i class="theme-switch fa-solid fa-moon fa-lg" data-mode="dark" title="Dark"></i>
<i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto" title="System Settings"></i>
</button></div>
<div class="navbar-item">
<div class="version-switcher__container dropdown pst-js-only">
<button id="pst-version-switcher-button-3"
type="button"
class="version-switcher__button btn btn-sm dropdown-toggle"
data-bs-toggle="dropdown"
aria-haspopup="listbox"
aria-controls="pst-version-switcher-list-3"
aria-label="Version switcher list"
>
Choose version <!-- this text may get changed later by javascript -->
<span class="caret"></span>
</button>
<div id="pst-version-switcher-list-3"
class="version-switcher__menu dropdown-menu list-group-flush py-0"
role="listbox" aria-labelledby="pst-version-switcher-button-3">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div></div>
<div class="navbar-item"><ul class="navbar-icon-links"
aria-label="Icon Links">
<li class="nav-item">
<a href="https://github.com/numpy/numpy" title="GitHub" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><i class="fa-brands fa-square-github fa-lg" aria-hidden="true"></i>
<span class="sr-only">GitHub</span></a>
</li>
</ul></div>
</div>
</div>
<div class="sidebar-primary-items__start sidebar-primary__section">
<div class="sidebar-primary-item">
<nav class="bd-docs-nav bd-links"
aria-label="Section Navigation">
<p class="bd-links__title" role="heading" aria-level="1">Section Navigation</p>
<div class="bd-toc-item navbar-nav"><p aria-level="2" class="caption" role="heading"><span class="caption-text">Getting started</span></p>
<ul class="nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="whatisnumpy.html">What is NumPy?</a></li>
<li class="toctree-l1"><a class="reference external" href="https://numpy.org/install/">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">NumPy quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="absolute_beginners.html">NumPy: the absolute basics for beginners</a></li>
</ul>
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Fundamentals and usage</span></p>
<ul class="current nav bd-sidenav">
<li class="toctree-l1 current active has-children"><a class="reference internal" href="basics.html">NumPy fundamentals</a><details open="open"><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="basics.creation.html">Array creation</a></li>
<li class="toctree-l2"><a class="reference internal" href="basics.indexing.html">Indexing on <code class="xref py py-class docutils literal notranslate"><span class="pre">ndarrays</span></code></a></li>
<li class="toctree-l2 current active has-children"><a class="reference internal" href="basics.io.html">I/O with NumPy</a><details open="open"><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul class="current">
<li class="toctree-l3 current active"><a class="current reference internal" href="#">Importing data with <code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></a></li>
</ul>
</details></li>
<li class="toctree-l2"><a class="reference internal" href="basics.types.html">Data types</a></li>
<li class="toctree-l2"><a class="reference internal" href="basics.broadcasting.html">Broadcasting</a></li>
<li class="toctree-l2"><a class="reference internal" href="basics.copies.html">Copies and views</a></li>
<li class="toctree-l2"><a class="reference internal" href="basics.strings.html">Working with Arrays of Strings And Bytes</a></li>
<li class="toctree-l2"><a class="reference internal" href="basics.rec.html">Structured arrays</a></li>
<li class="toctree-l2"><a class="reference internal" href="basics.ufuncs.html">Universal functions (<code class="xref py py-class docutils literal notranslate"><span class="pre">ufunc</span></code>) basics</a></li>
</ul>
</details></li>
</ul>
<ul class="nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="numpy-for-matlab-users.html">NumPy for MATLAB users</a></li>
<li class="toctree-l1"><a class="reference external" href="https://numpy.org/numpy-tutorials/">NumPy tutorials</a></li>
<li class="toctree-l1"><a class="reference internal" href="howtos_index.html">NumPy how-tos</a></li>
</ul>
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Advanced usage and interoperability</span></p>
<ul class="nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="c-info.html">Using NumPy C-API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../f2py/index.html">F2PY user guide and reference manual</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dev/underthehood.html">Under-the-hood documentation for developers</a></li>
<li class="toctree-l1"><a class="reference internal" href="basics.interoperability.html">Interoperability with NumPy</a></li>
</ul>
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Extras</span></p>
<ul class="nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="../release.html">Release notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../numpy_2_0_migration_guide.html">NumPy 2.0 migration guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../license.html">NumPy license</a></li>
</ul>
</div>
</nav></div>
</div>
<div class="sidebar-primary-items__end sidebar-primary__section">
<div class="sidebar-primary-item">
<div id="ethical-ad-placement"
class="flat"
data-ea-publisher="readthedocs"
data-ea-type="readthedocs-sidebar"
data-ea-manual="true">
</div></div>
</div>
</div>
<main id="main-content" class="bd-main" role="main">
<div class="bd-content">
<div class="bd-article-container">
<div class="bd-header-article d-print-none">
<div class="header-article-items header-article__inner">
<div class="header-article-items__start">
<div class="header-article-item">
<nav aria-label="Breadcrumb" class="d-print-none">
<ul class="bd-breadcrumbs">
<li class="breadcrumb-item breadcrumb-home">
<a href="../index.html" class="nav-link" aria-label="Home">
<i class="fa-solid fa-home"></i>
</a>
</li>
<li class="breadcrumb-item"><a href="index.html" class="nav-link">NumPy user guide</a></li>
<li class="breadcrumb-item"><a href="basics.html" class="nav-link">NumPy fundamentals</a></li>
<li class="breadcrumb-item"><a href="basics.io.html" class="nav-link">I/O with NumPy</a></li>
<li class="breadcrumb-item active" aria-current="page"><span class="ellipsis">Importing data with <code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></span></li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<div id="searchbox"></div>
<article class="bd-article">
<section id="importing-data-with-genfromtxt">
<h1>Importing data with <a class="reference internal" href="../reference/generated/numpy.genfromtxt.html#numpy.genfromtxt" title="numpy.genfromtxt"><code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></a><a class="headerlink" href="#importing-data-with-genfromtxt" title="Link to this heading">#</a></h1>
<p>NumPy provides several functions to create arrays from tabular data.
We focus here on the <a class="reference internal" href="../reference/generated/numpy.genfromtxt.html#numpy.genfromtxt" title="numpy.genfromtxt"><code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></a> function.</p>
<p>In a nutshell, <a class="reference internal" href="../reference/generated/numpy.genfromtxt.html#numpy.genfromtxt" title="numpy.genfromtxt"><code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></a> runs two main loops. The first
loop converts each line of the file in a sequence of strings. The second
loop converts each string to the appropriate data type. This mechanism is
slower than a single loop, but gives more flexibility. In particular,
<a class="reference internal" href="../reference/generated/numpy.genfromtxt.html#numpy.genfromtxt" title="numpy.genfromtxt"><code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></a> is able to take missing data into account, when
other faster and simpler functions like <a class="reference internal" href="../reference/generated/numpy.loadtxt.html#numpy.loadtxt" title="numpy.loadtxt"><code class="xref py py-func docutils literal notranslate"><span class="pre">loadtxt</span></code></a> cannot.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>When giving examples, we will use the following conventions:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span>
<span class="gp">>>> </span><span class="kn">from</span><span class="w"> </span><span class="nn">io</span><span class="w"> </span><span class="kn">import</span> <span class="n">StringIO</span>
</pre></div>
</div>
</div>
<section id="defining-the-input">
<h2>Defining the input<a class="headerlink" href="#defining-the-input" title="Link to this heading">#</a></h2>
<p>The only mandatory argument of <a class="reference internal" href="../reference/generated/numpy.genfromtxt.html#numpy.genfromtxt" title="numpy.genfromtxt"><code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></a> is the source of
the data. It can be a string, a list of strings, a generator or an open
file-like object with a <code class="docutils literal notranslate"><span class="pre">read</span></code> method, for example, a file or
<a class="reference external" href="https://docs.python.org/3/library/io.html#io.StringIO" title="(in Python v3.14)"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.StringIO</span></code></a> object. If a single string is provided, it is assumed
to be the name of a local or remote file. If a list of strings or a generator
returning strings is provided, each string is treated as one line in a file.
When the URL of a remote file is passed, the file is automatically downloaded
to the current directory and opened.</p>
<p>Recognized file types are text files and archives. Currently, the function
recognizes <code class="docutils literal notranslate"><span class="pre">gzip</span></code> and <code class="docutils literal notranslate"><span class="pre">bz2</span></code> (<code class="docutils literal notranslate"><span class="pre">bzip2</span></code>) archives. The type of
the archive is determined from the extension of the file: if the filename
ends with <code class="docutils literal notranslate"><span class="pre">'.gz'</span></code>, a <code class="docutils literal notranslate"><span class="pre">gzip</span></code> archive is expected; if it ends with
<code class="docutils literal notranslate"><span class="pre">'bz2'</span></code>, a <code class="docutils literal notranslate"><span class="pre">bzip2</span></code> archive is assumed.</p>
</section>
<section id="splitting-the-lines-into-columns">
<h2>Splitting the lines into columns<a class="headerlink" href="#splitting-the-lines-into-columns" title="Link to this heading">#</a></h2>
<section id="the-delimiter-argument">
<h3>The <code class="docutils literal notranslate"><span class="pre">delimiter</span></code> argument<a class="headerlink" href="#the-delimiter-argument" title="Link to this heading">#</a></h3>
<p>Once the file is defined and open for reading, <a class="reference internal" href="../reference/generated/numpy.genfromtxt.html#numpy.genfromtxt" title="numpy.genfromtxt"><code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></a>
splits each non-empty line into a sequence of strings. Empty or commented
lines are just skipped. The <code class="docutils literal notranslate"><span class="pre">delimiter</span></code> keyword is used to define
how the splitting should take place.</p>
<p>Quite often, a single character marks the separation between columns. For
example, comma-separated files (CSV) use a comma (<code class="docutils literal notranslate"><span class="pre">,</span></code>) or a semicolon
(<code class="docutils literal notranslate"><span class="pre">;</span></code>) as delimiter:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="s2">"1, 2, 3</span><span class="se">\n</span><span class="s2">4, 5, 6"</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">delimiter</span><span class="o">=</span><span class="s2">","</span><span class="p">)</span>
<span class="go">array([[1., 2., 3.],</span>
<span class="go"> [4., 5., 6.]])</span>
</pre></div>
</div>
<p>Another common separator is <code class="docutils literal notranslate"><span class="pre">"\t"</span></code>, the tabulation character. However,
we are not limited to a single character, any string will do. By default,
<a class="reference internal" href="../reference/generated/numpy.genfromtxt.html#numpy.genfromtxt" title="numpy.genfromtxt"><code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></a> assumes <code class="docutils literal notranslate"><span class="pre">delimiter=None</span></code>, meaning that the line
is split along white spaces (including tabs) and that consecutive white
spaces are considered as a single white space.</p>
<p>Alternatively, we may be dealing with a fixed-width file, where columns are
defined as a given number of characters. In that case, we need to set
<code class="docutils literal notranslate"><span class="pre">delimiter</span></code> to a single integer (if all the columns have the same
size) or to a sequence of integers (if columns can have different sizes):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="s2">" 1 2 3</span><span class="se">\n</span><span class="s2"> 4 5 67</span><span class="se">\n</span><span class="s2">890123 4"</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">delimiter</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
<span class="go">array([[ 1., 2., 3.],</span>
<span class="go"> [ 4., 5., 67.],</span>
<span class="go"> [890., 123., 4.]])</span>
<span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="s2">"123456789</span><span class="se">\n</span><span class="s2"> 4 7 9</span><span class="se">\n</span><span class="s2"> 4567 9"</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">delimiter</span><span class="o">=</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span>
<span class="go">array([[1234., 567., 89.],</span>
<span class="go"> [ 4., 7., 9.],</span>
<span class="go"> [ 4., 567., 9.]])</span>
</pre></div>
</div>
</section>
<section id="the-autostrip-argument">
<h3>The <code class="docutils literal notranslate"><span class="pre">autostrip</span></code> argument<a class="headerlink" href="#the-autostrip-argument" title="Link to this heading">#</a></h3>
<p>By default, when a line is decomposed into a series of strings, the
individual entries are not stripped of leading nor trailing white spaces.
This behavior can be overwritten by setting the optional argument
<code class="docutils literal notranslate"><span class="pre">autostrip</span></code> to a value of <code class="docutils literal notranslate"><span class="pre">True</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="s2">"1, abc , 2</span><span class="se">\n</span><span class="s2"> 3, xxx, 4"</span>
<span class="gp">>>> </span><span class="c1"># Without autostrip</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">delimiter</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="s2">"|U5"</span><span class="p">)</span>
<span class="go">array([['1', ' abc ', ' 2'],</span>
<span class="go"> ['3', ' xxx', ' 4']], dtype='<U5')</span>
<span class="gp">>>> </span><span class="c1"># With autostrip</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">delimiter</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="s2">"|U5"</span><span class="p">,</span> <span class="n">autostrip</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">array([['1', 'abc', '2'],</span>
<span class="go"> ['3', 'xxx', '4']], dtype='<U5')</span>
</pre></div>
</div>
</section>
<section id="the-comments-argument">
<h3>The <code class="docutils literal notranslate"><span class="pre">comments</span></code> argument<a class="headerlink" href="#the-comments-argument" title="Link to this heading">#</a></h3>
<p>The optional argument <code class="docutils literal notranslate"><span class="pre">comments</span></code> is used to define a character
string that marks the beginning of a comment. By default,
<a class="reference internal" href="../reference/generated/numpy.genfromtxt.html#numpy.genfromtxt" title="numpy.genfromtxt"><code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></a> assumes <code class="docutils literal notranslate"><span class="pre">comments='#'</span></code>. The comment marker may
occur anywhere on the line. Any character present after the comment
marker(s) is simply ignored:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="s2">"""#</span>
<span class="gp">... </span><span class="s2"># Skip me !</span>
<span class="gp">... </span><span class="s2"># Skip me too !</span>
<span class="gp">... </span><span class="s2">1, 2</span>
<span class="gp">... </span><span class="s2">3, 4</span>
<span class="gp">... </span><span class="s2">5, 6 #This is the third line of the data</span>
<span class="gp">... </span><span class="s2">7, 8</span>
<span class="gp">... </span><span class="s2"># And here comes the last line</span>
<span class="gp">... </span><span class="s2">9, 0</span>
<span class="gp">... </span><span class="s2">"""</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">comments</span><span class="o">=</span><span class="s2">"#"</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s2">","</span><span class="p">)</span>
<span class="go">array([[1., 2.],</span>
<span class="go"> [3., 4.],</span>
<span class="go"> [5., 6.],</span>
<span class="go"> [7., 8.],</span>
<span class="go"> [9., 0.]])</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>There is one notable exception to this behavior: if the optional argument
<code class="docutils literal notranslate"><span class="pre">names=True</span></code>, the first commented line will be examined for names.</p>
</div>
</section>
</section>
<section id="skipping-lines-and-choosing-columns">
<h2>Skipping lines and choosing columns<a class="headerlink" href="#skipping-lines-and-choosing-columns" title="Link to this heading">#</a></h2>
<section id="the-skip-header-and-skip-footer-arguments">
<h3>The <code class="docutils literal notranslate"><span class="pre">skip_header</span></code> and <code class="docutils literal notranslate"><span class="pre">skip_footer</span></code> arguments<a class="headerlink" href="#the-skip-header-and-skip-footer-arguments" title="Link to this heading">#</a></h3>
<p>The presence of a header in the file can hinder data processing. In that
case, we need to use the <code class="docutils literal notranslate"><span class="pre">skip_header</span></code> optional argument. The
values of this argument must be an integer which corresponds to the number
of lines to skip at the beginning of the file, before any other action is
performed. Similarly, we can skip the last <code class="docutils literal notranslate"><span class="pre">n</span></code> lines of the file by
using the <code class="docutils literal notranslate"><span class="pre">skip_footer</span></code> attribute and giving it a value of <code class="docutils literal notranslate"><span class="pre">n</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">))</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),)</span>
<span class="go">array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">skip_header</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">skip_footer</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
<span class="go">array([3., 4.])</span>
</pre></div>
</div>
<p>By default, <code class="docutils literal notranslate"><span class="pre">skip_header=0</span></code> and <code class="docutils literal notranslate"><span class="pre">skip_footer=0</span></code>, meaning that no lines
are skipped.</p>
</section>
<section id="the-usecols-argument">
<h3>The <code class="docutils literal notranslate"><span class="pre">usecols</span></code> argument<a class="headerlink" href="#the-usecols-argument" title="Link to this heading">#</a></h3>
<p>In some cases, we are not interested in all the columns of the data but
only a few of them. We can select which columns to import with the
<code class="docutils literal notranslate"><span class="pre">usecols</span></code> argument. This argument accepts a single integer or a
sequence of integers corresponding to the indices of the columns to import.
Remember that by convention, the first column has an index of 0. Negative
integers behave the same as regular Python negative indexes.</p>
<p>For example, if we want to import only the first and the last columns, we
can use <code class="docutils literal notranslate"><span class="pre">usecols=(0,</span> <span class="pre">-1)</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="s2">"1 2 3</span><span class="se">\n</span><span class="s2">4 5 6"</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">usecols</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">))</span>
<span class="go">array([[1., 3.],</span>
<span class="go"> [4., 6.]])</span>
</pre></div>
</div>
<p>If the columns have names, we can also select which columns to import by
giving their name to the <code class="docutils literal notranslate"><span class="pre">usecols</span></code> argument, either as a sequence
of strings or a comma-separated string:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="s2">"1 2 3</span><span class="se">\n</span><span class="s2">4 5 6"</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">names</span><span class="o">=</span><span class="s2">"a, b, c"</span><span class="p">,</span> <span class="n">usecols</span><span class="o">=</span><span class="p">(</span><span class="s2">"a"</span><span class="p">,</span> <span class="s2">"c"</span><span class="p">))</span>
<span class="go">array([(1., 3.), (4., 6.)], dtype=[('a', '<f8'), ('c', '<f8')])</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">names</span><span class="o">=</span><span class="s2">"a, b, c"</span><span class="p">,</span> <span class="n">usecols</span><span class="o">=</span><span class="p">(</span><span class="s2">"a, c"</span><span class="p">))</span>
<span class="go"> array([(1., 3.), (4., 6.)], dtype=[('a', '<f8'), ('c', '<f8')])</span>
</pre></div>
</div>
</section>
</section>
<section id="choosing-the-data-type">
<h2>Choosing the data type<a class="headerlink" href="#choosing-the-data-type" title="Link to this heading">#</a></h2>
<p>The main way to control how the sequences of strings we have read from the
file are converted to other types is to set the <code class="docutils literal notranslate"><span class="pre">dtype</span></code> argument.
Acceptable values for this argument are:</p>
<ul class="simple">
<li><p>a single type, such as <code class="docutils literal notranslate"><span class="pre">dtype=np.float64</span></code>.
The output will be 2D with the given dtype, unless a name has been
associated with each column with the use of the <code class="docutils literal notranslate"><span class="pre">names</span></code> argument
(see below). Note that <code class="docutils literal notranslate"><span class="pre">dtype=np.float64</span></code> is the default for
<a class="reference internal" href="../reference/generated/numpy.genfromtxt.html#numpy.genfromtxt" title="numpy.genfromtxt"><code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></a>.</p></li>
<li><p>a sequence of types, such as <code class="docutils literal notranslate"><span class="pre">dtype=(np.int_,</span> <span class="pre">np.float64,</span> <span class="pre">np.float64)</span></code>.</p></li>
<li><p>a comma-separated string, such as <code class="docutils literal notranslate"><span class="pre">dtype="i4,f8,|U3"</span></code>.</p></li>
<li><p>a dictionary with two keys <code class="docutils literal notranslate"><span class="pre">'names'</span></code> and <code class="docutils literal notranslate"><span class="pre">'formats'</span></code>.</p></li>
<li><p>a sequence of tuples <code class="docutils literal notranslate"><span class="pre">(name,</span> <span class="pre">type)</span></code>, such as
<code class="docutils literal notranslate"><span class="pre">dtype=[('A',</span> <span class="pre">np.int_),</span> <span class="pre">('B',</span> <span class="pre">np.float64)]</span></code>.</p></li>
<li><p>an existing <a class="reference internal" href="../reference/generated/numpy.dtype.html#numpy.dtype" title="numpy.dtype"><code class="xref py py-class docutils literal notranslate"><span class="pre">numpy.dtype</span></code></a> object.</p></li>
<li><p>the special value <code class="docutils literal notranslate"><span class="pre">None</span></code>.
In that case, the type of the columns will be determined from the data
itself (see below).</p></li>
</ul>
<p>In all the cases but the first one, the output will be a 1D array with a
structured dtype. This dtype has as many fields as items in the sequence.
The field names are defined with the <code class="docutils literal notranslate"><span class="pre">names</span></code> keyword.</p>
<p>When <code class="docutils literal notranslate"><span class="pre">dtype=None</span></code>, the type of each column is determined iteratively from
its data. We start by checking whether a string can be converted to a
boolean (that is, if the string matches <code class="docutils literal notranslate"><span class="pre">true</span></code> or <code class="docutils literal notranslate"><span class="pre">false</span></code> in lower
cases); then whether it can be converted to an integer, then to a float,
then to a complex and eventually to a string.</p>
<p>The option <code class="docutils literal notranslate"><span class="pre">dtype=None</span></code> is provided for convenience. However, it is
significantly slower than setting the dtype explicitly.</p>
</section>
<section id="setting-the-names">
<h2>Setting the names<a class="headerlink" href="#setting-the-names" title="Link to this heading">#</a></h2>
<section id="the-names-argument">
<h3>The <code class="docutils literal notranslate"><span class="pre">names</span></code> argument<a class="headerlink" href="#the-names-argument" title="Link to this heading">#</a></h3>
<p>A natural approach when dealing with tabular data is to allocate a name to
each column. A first possibility is to use an explicit structured dtype,
as mentioned previously:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="n">StringIO</span><span class="p">(</span><span class="s2">"1 2 3</span><span class="se">\n</span><span class="s2"> 4 5 6"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="p">[(</span><span class="n">_</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int_</span><span class="p">)</span> <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="s2">"abc"</span><span class="p">])</span>
<span class="go">array([(1, 2, 3), (4, 5, 6)],</span>
<span class="go"> dtype=[('a', '<i8'), ('b', '<i8'), ('c', '<i8')])</span>
</pre></div>
</div>
<p>Another simpler possibility is to use the <code class="docutils literal notranslate"><span class="pre">names</span></code> keyword with a
sequence of strings or a comma-separated string:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="n">StringIO</span><span class="p">(</span><span class="s2">"1 2 3</span><span class="se">\n</span><span class="s2"> 4 5 6"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">names</span><span class="o">=</span><span class="s2">"A, B, C"</span><span class="p">)</span>
<span class="go">array([(1., 2., 3.), (4., 5., 6.)],</span>
<span class="go"> dtype=[('A', '<f8'), ('B', '<f8'), ('C', '<f8')])</span>
</pre></div>
</div>
<p>In the example above, we used the fact that by default, <code class="docutils literal notranslate"><span class="pre">dtype=np.float64</span></code>.
By giving a sequence of names, we are forcing the output to a structured
dtype.</p>
<p>We may sometimes need to define the column names from the data itself. In
that case, we must use the <code class="docutils literal notranslate"><span class="pre">names</span></code> keyword with a value of
<code class="docutils literal notranslate"><span class="pre">True</span></code>. The names will then be read from the first line (after the
<code class="docutils literal notranslate"><span class="pre">skip_header</span></code> ones), even if the line is commented out:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="n">StringIO</span><span class="p">(</span><span class="s2">"So it goes</span><span class="se">\n</span><span class="s2">#a b c</span><span class="se">\n</span><span class="s2">1 2 3</span><span class="se">\n</span><span class="s2"> 4 5 6"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">skip_header</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">names</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">array([(1., 2., 3.), (4., 5., 6.)],</span>
<span class="go"> dtype=[('a', '<f8'), ('b', '<f8'), ('c', '<f8')])</span>
</pre></div>
</div>
<p>The default value of <code class="docutils literal notranslate"><span class="pre">names</span></code> is <code class="docutils literal notranslate"><span class="pre">None</span></code>. If we give any other
value to the keyword, the new names will overwrite the field names we may
have defined with the dtype:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="n">StringIO</span><span class="p">(</span><span class="s2">"1 2 3</span><span class="se">\n</span><span class="s2"> 4 5 6"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">ndtype</span><span class="o">=</span><span class="p">[(</span><span class="s1">'a'</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int_</span><span class="p">),</span> <span class="p">(</span><span class="s1">'b'</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">),</span> <span class="p">(</span><span class="s1">'c'</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int_</span><span class="p">)]</span>
<span class="gp">>>> </span><span class="n">names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"A"</span><span class="p">,</span> <span class="s2">"B"</span><span class="p">,</span> <span class="s2">"C"</span><span class="p">]</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">names</span><span class="o">=</span><span class="n">names</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">ndtype</span><span class="p">)</span>
<span class="go">array([(1, 2., 3), (4, 5., 6)],</span>
<span class="go"> dtype=[('A', '<i8'), ('B', '<f8'), ('C', '<i8')])</span>
</pre></div>
</div>
</section>
<section id="the-defaultfmt-argument">
<h3>The <code class="docutils literal notranslate"><span class="pre">defaultfmt</span></code> argument<a class="headerlink" href="#the-defaultfmt-argument" title="Link to this heading">#</a></h3>
<p>If <code class="docutils literal notranslate"><span class="pre">names=None</span></code> but a structured dtype is expected, names are defined
with the standard NumPy default of <code class="docutils literal notranslate"><span class="pre">"f%i"</span></code>, yielding names like <code class="docutils literal notranslate"><span class="pre">f0</span></code>,
<code class="docutils literal notranslate"><span class="pre">f1</span></code> and so forth:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="n">StringIO</span><span class="p">(</span><span class="s2">"1 2 3</span><span class="se">\n</span><span class="s2"> 4 5 6"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">int_</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int_</span><span class="p">))</span>
<span class="go">array([(1, 2., 3), (4, 5., 6)],</span>
<span class="go"> dtype=[('f0', '<i8'), ('f1', '<f8'), ('f2', '<i8')])</span>
</pre></div>
</div>
<p>In the same way, if we don’t give enough names to match the length of the
dtype, the missing names will be defined with this default template:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="n">StringIO</span><span class="p">(</span><span class="s2">"1 2 3</span><span class="se">\n</span><span class="s2"> 4 5 6"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">int_</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int_</span><span class="p">),</span> <span class="n">names</span><span class="o">=</span><span class="s2">"a"</span><span class="p">)</span>
<span class="go">array([(1, 2., 3), (4, 5., 6)],</span>
<span class="go"> dtype=[('a', '<i8'), ('f0', '<f8'), ('f1', '<i8')])</span>
</pre></div>
</div>
<p>We can overwrite this default with the <code class="docutils literal notranslate"><span class="pre">defaultfmt</span></code> argument, that
takes any format string:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="n">StringIO</span><span class="p">(</span><span class="s2">"1 2 3</span><span class="se">\n</span><span class="s2"> 4 5 6"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">int_</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int_</span><span class="p">),</span> <span class="n">defaultfmt</span><span class="o">=</span><span class="s2">"var_</span><span class="si">%02i</span><span class="s2">"</span><span class="p">)</span>
<span class="go">array([(1, 2., 3), (4, 5., 6)],</span>
<span class="go"> dtype=[('var_00', '<i8'), ('var_01', '<f8'), ('var_02', '<i8')])</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>We need to keep in mind that <code class="docutils literal notranslate"><span class="pre">defaultfmt</span></code> is used only if some names
are expected but not defined.</p>
</div>
</section>
<section id="validating-names">
<h3>Validating names<a class="headerlink" href="#validating-names" title="Link to this heading">#</a></h3>
<p>NumPy arrays with a structured dtype can also be viewed as
<a class="reference internal" href="../reference/generated/numpy.recarray.html#numpy.recarray" title="numpy.recarray"><code class="xref py py-class docutils literal notranslate"><span class="pre">recarray</span></code></a>, where a field can be accessed as if it were an
attribute. For that reason, we may need to make sure that the field name
doesn’t contain any space or invalid character, or that it does not
correspond to the name of a standard attribute (like <code class="docutils literal notranslate"><span class="pre">size</span></code> or
<code class="docutils literal notranslate"><span class="pre">shape</span></code>), which would confuse the interpreter. <a class="reference internal" href="../reference/generated/numpy.genfromtxt.html#numpy.genfromtxt" title="numpy.genfromtxt"><code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></a>
accepts three optional arguments that provide a finer control on the names:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">deletechars</span></code></dt><dd><p>Gives a string combining all the characters that must be deleted from
the name. By default, invalid characters are
<code class="docutils literal notranslate"><span class="pre">~!@#$%^&*()-=+~\|]}[{';:</span>
<span class="pre">/?.>,<</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">excludelist</span></code></dt><dd><p>Gives a list of the names to exclude, such as <code class="docutils literal notranslate"><span class="pre">return</span></code>, <code class="docutils literal notranslate"><span class="pre">file</span></code>,
<code class="docutils literal notranslate"><span class="pre">print</span></code>… If one of the input name is part of this list, an
underscore character (<code class="docutils literal notranslate"><span class="pre">'_'</span></code>) will be appended to it.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">case_sensitive</span></code></dt><dd><p>Whether the names should be case-sensitive (<code class="docutils literal notranslate"><span class="pre">case_sensitive=True</span></code>),
converted to upper case (<code class="docutils literal notranslate"><span class="pre">case_sensitive=False</span></code> or
<code class="docutils literal notranslate"><span class="pre">case_sensitive='upper'</span></code>) or to lower case
(<code class="docutils literal notranslate"><span class="pre">case_sensitive='lower'</span></code>).</p>
</dd>
</dl>
</section>
</section>
<section id="tweaking-the-conversion">
<h2>Tweaking the conversion<a class="headerlink" href="#tweaking-the-conversion" title="Link to this heading">#</a></h2>
<section id="the-converters-argument">
<h3>The <code class="docutils literal notranslate"><span class="pre">converters</span></code> argument<a class="headerlink" href="#the-converters-argument" title="Link to this heading">#</a></h3>
<p>Usually, defining a dtype is sufficient to define how the sequence of
strings must be converted. However, some additional control may sometimes
be required. For example, we may want to make sure that a date in a format
<code class="docutils literal notranslate"><span class="pre">YYYY/MM/DD</span></code> is converted to a <a class="reference external" href="https://docs.python.org/3/library/datetime.html#datetime.datetime" title="(in Python v3.14)"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime</span></code></a> object, or that
a string like <code class="docutils literal notranslate"><span class="pre">xx%</span></code> is properly converted to a float between 0 and 1. In
such cases, we should define conversion functions with the <code class="docutils literal notranslate"><span class="pre">converters</span></code>
arguments.</p>
<p>The value of this argument is typically a dictionary with column indices or
column names as keys and a conversion functions as values. These
conversion functions can either be actual functions or lambda functions. In
any case, they should accept only a string as input and output only a
single element of the wanted type.</p>
<p>In the following example, the second column is converted from as string
representing a percentage to a float between 0 and 1:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">convertfunc</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="nb">float</span><span class="p">(</span><span class="n">x</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s2">"%"</span><span class="p">))</span><span class="o">/</span><span class="mf">100.</span>
<span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="s2">"1, 2.3%, 45.</span><span class="se">\n</span><span class="s2">6, 78.9%, 0"</span>
<span class="gp">>>> </span><span class="n">names</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"i"</span><span class="p">,</span> <span class="s2">"p"</span><span class="p">,</span> <span class="s2">"n"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="c1"># General case .....</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">delimiter</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> <span class="n">names</span><span class="o">=</span><span class="n">names</span><span class="p">)</span>
<span class="go">array([(1., nan, 45.), (6., nan, 0.)],</span>
<span class="go"> dtype=[('i', '<f8'), ('p', '<f8'), ('n', '<f8')])</span>
</pre></div>
</div>
<p>We need to keep in mind that by default, <code class="docutils literal notranslate"><span class="pre">dtype=np.float64</span></code>. A float is
therefore expected for the second column. However, the strings <code class="docutils literal notranslate"><span class="pre">'</span> <span class="pre">2.3%'</span></code>
and <code class="docutils literal notranslate"><span class="pre">'</span> <span class="pre">78.9%'</span></code> cannot be converted to float and we end up having
<code class="docutils literal notranslate"><span class="pre">np.nan</span></code> instead. Let’s now use a converter:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># Converted case ...</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">delimiter</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> <span class="n">names</span><span class="o">=</span><span class="n">names</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">converters</span><span class="o">=</span><span class="p">{</span><span class="mi">1</span><span class="p">:</span> <span class="n">convertfunc</span><span class="p">})</span>
<span class="go">array([(1., 0.023, 45.), (6., 0.789, 0.)],</span>
<span class="go"> dtype=[('i', '<f8'), ('p', '<f8'), ('n', '<f8')])</span>
</pre></div>
</div>
<p>The same results can be obtained by using the name of the second column
(<code class="docutils literal notranslate"><span class="pre">"p"</span></code>) as key instead of its index (1):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># Using a name for the converter ...</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">delimiter</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> <span class="n">names</span><span class="o">=</span><span class="n">names</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">converters</span><span class="o">=</span><span class="p">{</span><span class="s2">"p"</span><span class="p">:</span> <span class="n">convertfunc</span><span class="p">})</span>
<span class="go">array([(1., 0.023, 45.), (6., 0.789, 0.)],</span>
<span class="go"> dtype=[('i', '<f8'), ('p', '<f8'), ('n', '<f8')])</span>
</pre></div>
</div>
<p>Converters can also be used to provide a default for missing entries. In
the following example, the converter <code class="docutils literal notranslate"><span class="pre">convert</span></code> transforms a stripped
string into the corresponding float or into -999 if the string is empty.
We need to explicitly strip the string from white spaces as it is not done
by default:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="s2">"1, , 3</span><span class="se">\n</span><span class="s2"> 4, 5, 6"</span>
<span class="gp">>>> </span><span class="n">convert</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="nb">float</span><span class="p">(</span><span class="n">x</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="ow">or</span> <span class="o">-</span><span class="mi">999</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="n">delimiter</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">converters</span><span class="o">=</span><span class="p">{</span><span class="mi">1</span><span class="p">:</span> <span class="n">convert</span><span class="p">})</span>
<span class="go">array([[ 1., -999., 3.],</span>
<span class="go"> [ 4., 5., 6.]])</span>
</pre></div>
</div>
</section>
<section id="using-missing-and-filling-values">
<h3>Using missing and filling values<a class="headerlink" href="#using-missing-and-filling-values" title="Link to this heading">#</a></h3>
<p>Some entries may be missing in the dataset we are trying to import. In a
previous example, we used a converter to transform an empty string into a
float. However, user-defined converters may rapidly become cumbersome to
manage.</p>
<p>The <a class="reference internal" href="../reference/generated/numpy.genfromtxt.html#numpy.genfromtxt" title="numpy.genfromtxt"><code class="xref py py-func docutils literal notranslate"><span class="pre">genfromtxt</span></code></a> function provides two other complementary
mechanisms: the <code class="docutils literal notranslate"><span class="pre">missing_values</span></code> argument is used to recognize
missing data and a second argument, <code class="docutils literal notranslate"><span class="pre">filling_values</span></code>, is used to
process these missing data.</p>
</section>
<section id="missing-values">
<h3><code class="docutils literal notranslate"><span class="pre">missing_values</span></code><a class="headerlink" href="#missing-values" title="Link to this heading">#</a></h3>
<p>By default, any empty string is marked as missing. We can also consider
more complex strings, such as <code class="docutils literal notranslate"><span class="pre">"N/A"</span></code> or <code class="docutils literal notranslate"><span class="pre">"???"</span></code> to represent missing
or invalid data. The <code class="docutils literal notranslate"><span class="pre">missing_values</span></code> argument accepts three kinds
of values:</p>
<dl class="simple">
<dt>a string or a comma-separated string</dt><dd><p>This string will be used as the marker for missing data for all the
columns</p>
</dd>
<dt>a sequence of strings</dt><dd><p>In that case, each item is associated to a column, in order.</p>
</dd>
<dt>a dictionary</dt><dd><p>Values of the dictionary are strings or sequence of strings. The
corresponding keys can be column indices (integers) or column names
(strings). In addition, the special key <code class="docutils literal notranslate"><span class="pre">None</span></code> can be used to
define a default applicable to all columns.</p>
</dd>
</dl>
</section>
<section id="filling-values">
<h3><code class="docutils literal notranslate"><span class="pre">filling_values</span></code><a class="headerlink" href="#filling-values" title="Link to this heading">#</a></h3>
<p>We know how to recognize missing data, but we still need to provide a value
for these missing entries. By default, this value is determined from the
expected dtype according to this table:</p>
<div class="pst-scrollable-table-container"><table class="table">
<thead>
<tr class="row-odd"><th class="head"><p>Expected type</p></th>
<th class="head"><p>Default</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">bool</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">False</span></code></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">int</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">-1</span></code></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">np.nan</span></code></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">complex</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">np.nan+0j</span></code></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">string</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">'???'</span></code></p></td>
</tr>
</tbody>
</table>
</div>
<p>We can get a finer control on the conversion of missing values with the
<code class="docutils literal notranslate"><span class="pre">filling_values</span></code> optional argument. Like
<code class="docutils literal notranslate"><span class="pre">missing_values</span></code>, this argument accepts different kind of values:</p>
<dl class="simple">
<dt>a single value</dt><dd><p>This will be the default for all columns</p>
</dd>
<dt>a sequence of values</dt><dd><p>Each entry will be the default for the corresponding column</p>
</dd>
<dt>a dictionary</dt><dd><p>Each key can be a column index or a column name, and the
corresponding value should be a single object. We can use the
special key <code class="docutils literal notranslate"><span class="pre">None</span></code> to define a default for all columns.</p>
</dd>
</dl>
<p>In the following example, we suppose that the missing values are flagged
with <code class="docutils literal notranslate"><span class="pre">"N/A"</span></code> in the first column and by <code class="docutils literal notranslate"><span class="pre">"???"</span></code> in the third column.
We wish to transform these missing values to 0 if they occur in the first
and second column, and to -999 if they occur in the last column:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="s2">"N/A, 2, 3</span><span class="se">\n</span><span class="s2">4, ,???"</span>
<span class="gp">>>> </span><span class="n">kwargs</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">delimiter</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">int_</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">names</span><span class="o">=</span><span class="s2">"a,b,c"</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">missing_values</span><span class="o">=</span><span class="p">{</span><span class="mi">0</span><span class="p">:</span><span class="s2">"N/A"</span><span class="p">,</span> <span class="s1">'b'</span><span class="p">:</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">2</span><span class="p">:</span><span class="s2">"???"</span><span class="p">},</span>
<span class="gp">... </span> <span class="n">filling_values</span><span class="o">=</span><span class="p">{</span><span class="mi">0</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span> <span class="s1">'b'</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">:</span><span class="o">-</span><span class="mi">999</span><span class="p">})</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">genfromtxt</span><span class="p">(</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="go">array([(0, 2, 3), (4, 0, -999)],</span>
<span class="go"> dtype=[('a', '<i8'), ('b', '<i8'), ('c', '<i8')])</span>
</pre></div>
</div>
</section>
<section id="usemask">
<h3><code class="docutils literal notranslate"><span class="pre">usemask</span></code><a class="headerlink" href="#usemask" title="Link to this heading">#</a></h3>
<p>We may also want to keep track of the occurrence of missing data by
constructing a boolean mask, with <code class="docutils literal notranslate"><span class="pre">True</span></code> entries where data was missing
and <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise. To do that, we just have to set the optional
argument <code class="docutils literal notranslate"><span class="pre">usemask</span></code> to <code class="docutils literal notranslate"><span class="pre">True</span></code> (the default is <code class="docutils literal notranslate"><span class="pre">False</span></code>). The
output array will then be a <a class="reference internal" href="../reference/maskedarray.baseclass.html#numpy.ma.MaskedArray" title="numpy.ma.MaskedArray"><code class="xref py py-class docutils literal notranslate"><span class="pre">MaskedArray</span></code></a>.</p>