docs: def read(file):
      """Read in a file and create a data strucuture that is a hash with members 'header'
      and 'data'.  The 'header' is a hash of header keywords, the data is a hash of columns.
  
      To get to the nth element of column NAME use hdu[data][NAME][n].  To get the header
      information use hdu[header][KEYWORD]. """
      
      f = open(file,'r')
      lines=f.readlines()
      f.close()
  
      import re, string
      keywords=[]
      values=[]
      formats={}
      header={}
      cdata={}
  
      for line in lines:
          if ( re.match(r'^##',line)):
              ## header line
              m=string.split(string.lstrip(line[2:]))
              if not m:
                  sys.stderr.write( "Ill formed header line in %s \ n " % ( file, ))
                  sys.stderr.write( line)
                  continue
              keywords=m
              add_id=False
              continue
          if ( re.match(r'^# ',line)):
              ## this is a keyword value line, must match the previous keyword line
              m=string.split(string.lstrip(line[1:]))
              values=m
              if len(values)!= len(keywords):
                  sys.stderr.write( "Ill formed header, keyword/value missmatach\n")
              for index in range(len(values)):
                  header[keywords[index]]=values[index]
  	    ## blank the arrays, we've already stuck this into the header
              keywords=[]
              values=[]
              continue
          if ( re.match(r'^#F',line)):
              ## this is a format line for the columns needs to be a keyword line first
              if not keywords:
                  sys.stderr.write("Cann't have formats without column names...\n")
                  continue
              f=string.split(string.lstrip(line))
              if add_id:
                  f.append('%8d')
              for col in keywords:
                  formats[col]=f.pop(0)
          ### must be the actual data
          ### expect a previous header line to define column headers
          if not keywords:
              sys.stderr.write( "No keywords for data columns, assuming x,y,mag,msky\n")
              keywords=('X','Y','MAG','MSKY')
          values = string.split(string.lstrip(line))
          ### add the id value to the values array if needed
          if not 'ID' in keywords:
              keywords.append('ID')
              add_id=True
          if not cdata:
              for keyword in keywords:
                  cdata[keyword]=[]
          if add_id:
              values.append(len(cdata[keywords[0]])+1) 
          if len(values)!=len(keywords):
              sys.stderr.write("Keyword and value index have different length?\n")
  	    continue
          for index in range(len(values)):
              cdata[keywords[index]].append(values[index])
  
      hdu={'data': cdata, 'header': header, 'format': formats, 'order': keywords}
      ### the hdu is a dictionary with the header and data
      return hdu