Thanks **cblake** & **choltreppe** :

I went with a slightly tailored version of **cblake** 's first macro.

  * assume already existing _vars_
  * pad with empty strings if too view items


    
    
    macro to[T](values: openArray[T], fieldNames: varargs[untyped]): untyped =
      result = newStmtList()
      for index, fieldName in fieldNames:
        result.add(quote do:
          (`fieldName` = (if `index` < `values`.len: `values`[`index`] else: 
"")))
    
    ...
      
      for line in lines:
        line.split('\t').to  title, pages, author # ... and lots more fieldnames
    
    
    
    Run

Reply via email to