0

I'm trying to read CSV files into Python with the numpy package. My row data has several entries such as 'VA, no longer in study'. The issue is that if I use np.genfromtxt to read in the file with ',' as the delimiter, it separates such entries as ['VA', 'no longer in study'] as opposed to ['VA, no longer in study']. Is there an option in the genfromtxt function that could help me avoid this issue or create a dialect allowing me to skip over these initial spaces?

Thanks in advance.

  • 2
    must numpy be used to solve your problem? because something like `pandas`, which works alongside numpy, could handle this well. – MattR Feb 15 '18 at 20:58
  • `genfromtxt` does not handle quoted strings. The `csv` module does. You could also preprocess the file, changing for example the real delimiters to something else. – hpaulj Feb 15 '18 at 21:04
  • Wait, you are trying to create an array of *strings*? – juanpa.arrivillaga Feb 15 '18 at 21:07

0 Answers0