File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change 1818
1919from __future__ import annotations
2020
21+ import csv
2122import os
2223import typing
2324from dataclasses import dataclass
@@ -147,13 +148,23 @@ def load(
147148 for filename in filenames :
148149 datafile_path = os .path .join (self .record .repository , "dataset" , filename )
149150
150- self ._content [filename .split ("." )[0 ]] = np .genfromtxt (
151- datafile_path ,
152- delimiter = "," ,
153- names = True ,
154- dtype = None ,
155- encoding = "utf-8" ,
156- )
151+ # NOTE: Use csv module to avoid NumPy 2.x genfromtxt dtype=None errors
152+ with open (datafile_path , encoding = "utf-8" ) as csvfile :
153+ reader = csv .reader (csvfile )
154+ headers = [h .strip ().replace (" " , "_" ) for h in next (reader )]
155+ rows = []
156+ for row in reader :
157+ converted = []
158+ for value in row :
159+ try :
160+ converted .append (float (value ))
161+ except ValueError :
162+ converted .append (value )
163+ rows .append (tuple (converted ))
164+
165+ dtypes = [(name , object ) for name in headers ]
166+ data = np .array (rows , dtype = dtypes )
167+ self ._content [filename .split ("." )[0 ]] = data
157168
158169 hues = [
159170 "Red" ,
You can’t perform that action at this time.
0 commit comments