0

I am trying to create a numpy array from a geosoft formatted xyz text file. The format uses a '/' to start the header file, then space delimited after. I believe numpy sees the '/' and assigns as column zero.

Header info looks like this

/ Line Aircraft Flight Date JulL Time DateU TimeU Zn Easting Northing Lat Long xTrack ZFid_ms KFid AFid TFRAWT TFUNCT Mag4D VecX VecY VecZ VecTF MagRatio GPSHt Undul Sats HDop DGPS RadAlt BaroHPa Temp Humid CurrAmps Dn Up Samp Live RawTC RawK RawU RawTh Cosm LRange LStr LErr

data = np.genfromtxt(filename, deletechars="/", usecols=(0,18,20,21,22,23),invalid_raise=False, names=True,dtype=None)

data.dtype.names results in below, first column did not create a valid column name

('f0', 'TFRAWT', 'Mag4D', 'VecX', 'VecY', 'VecZ')

I thought deletechars was built for this purpose? Am I not using it correctly?

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 20 '21 at 19:13
  • The header contains a '/' at the start which is causing problems. I would prefer not to read write an entire file to remove the very first character of the file to remedy the issue. Is there another way I can resolve this issue? Is there a function I am missing in genfromtxt? Can I edit an existing data.dtype.names before/during/after import? Can I create a list and assign as data.dtype.names? – AndrewTaylor Sep 21 '21 at 01:30

0 Answers0