public static Map<String,Integer> createIdxFromKey(String line,String fieldSeparator){
  String[] keys=line.split(fieldSeparator);
  Map<String,Integer> idxFromKey=new HashMap<String,Integer>();
  for (int ii=0; ii < keys.length; ii++) {
    idxFromKey.put(keys[ii],ii);
  }
  return idxFromKey;
}

public static Map < String , Integer > createIdxFromKey ( String line , String fieldSeparator ) { String [ ] keys = line . split ( fieldSeparator ) ; Map < String , Integer > idxFromKey = new HashMap < String , Integer > ( ) ; for ( int ii = 0 ; ii < keys . length ; ii ++ ) { idxFromKey . put ( keys [ ii ] , ii ) ; } return idxFromKey ; }
this is used to parse a header line from a tab - delimited urbansim header and generate a map that allows to look up column numbers ( starting from 0 ) by giving the header line . i . e . if you have a header " from_id < tab > to_id < tab > travel_time " , then idxfromkey . get ( " to_id " ) will return " 1 " . this makes the reading of column - oriented files independent from the sequence of the columns . could be made more general by putting the separator into the argument .
