Hi Kim,
I cannot replicate your problem, because after your second line I get:
% READ_CSV: Illegal subscript range: XDATA.
Reading the
docs it seems to me you mixed up
HEADER & TABLE_HEADER. With the following the read-in works for me:
CDATA = READ_CSV(F, HEADER=TAGS,MISSING_VALUE=-99999)
After that you don't have to apply STRSPLIT to TAGS.
This way I don't get the problem with the first tag.
As to the non-printable characters in the first tag in your version, use
print, byte(tags[0])
and then look up in an extended ASCII table.
If you cannot get READ_CSV to work, this should do:
nlines=file_lines(F)
lines=strarr(nlines)
openr,lun,F,/get_lun
readf,lun,lines
free_lun,lun
cstrings=(strsplit(lines,/extract,',',/preserve_null)).toArray()
tags=cstrings[0,*]
tags_valid=IDL_VALIDNAME(STRCOMPRESS(TAGS),/CONVERT_ALL)
defaults=list('','',0l,0l,0l,0d,0l,0d,0l,0l,0l,'','','',0l,0l)
oha=orderedhash(tags_valid,defaults.map(lambda('x:replicate(x,'+string(nlines-1)+')')))
cdata=oha.toStruct()
for i=0,n_elements(tags)-1 do cdata.(i)=cstrings[1:-1,i]
isString=defaults.map(lambda('x:isa(x,/string)'))
foreach w,isString.where(0) do cdata.(w)[where(cstrings[1:-1,w] eq '',/null)]=-99999
The only drawback of this code is, that you have to set the defaults manually.
Good luck, Markus
PS: Given that your IDL behaves differently than mine, here my version:
IDL> !version
{
"ARCH": "x86_64",
"OS": "linux",
"OS_FAMILY": "unix",
"OS_NAME": "linux",
"RELEASE": "8.5",
"BUILD_DATE": "Jul 7 2015",
"MEMORY_BITS": 64,
"FILE_OFFSET_BITS": 64
}