2

In Unidata, when dumping a query to a delimited file, e.g.

list MYFILE '1000' ATB1 ATB2 ATB3 TO DELIM "|" /tmp/extract.txt

Are there any UDT.OPTIONS that control if a heading row is written or not? The only workaround currently involves some really hokey BY.EXP action, and changing EVERY atb to be multivalued and return the heading:@VM:value if we're on the first row. That really, really, sucks.

Looking for something similar to UDT.OPTIONS 91 which controls whether external formatting is applied using TO DELIM.

Currently the output would be:

1000|100|200|300

And what I'm looking for is:

@ID|ATB1|ATB2|ATB3
1000|100|200|300
Ian McGowan
  • 3,461
  • 3
  • 18
  • 23
  • I don't have a quick and easy answer for you from the UniData side I am afraid, but this is the sort of annoyance that would make me write a little cataloged command line utility to run on top of an active select list in UniVerse. Something like LISTDELIM FILE "|" OUTPUTFILE COL1 COL2 COL3. I would then read the dictionary items and use their contents to convert and output them (manually or with ITYPE) to a sequential file. I looked that UniData ref and while your dictionary types make no sense to me, the functions seem to be the same. Good Luck! – Van Amburg Oct 19 '17 at 13:53
  • Van, thanks. This is part of a utility that creates xlsx files as zipped XML. I do have the "report" available, and can parse it to get dict/atb names, but because I'm parsing the users need to use a pretty rigid format - SSELECT before list/sort and I stop looking for atb's at the TO. If UD would just write the headings, the program would be a lot more general purpose! https://github.com/ianmcgowan/SCI.BP/blob/master/SCI.XLSX.RECALL GET.FIELD.NAMES is what I'd like to get rid of. – Ian McGowan Oct 23 '17 at 18:09

1 Answers1

1

Ian,

Have you looked at using TOXML, and then using the XDOMTransform function, to flatten it the way you want?

Mike

Mike
  • 194
  • 11
  • Doh! I had looked at TOXML initially because the ultimate target is to produce an XML document in the Microsoft Office XML format. That looks perfect for what I'm trying to do, thanks for the pointer! – Ian McGowan Dec 05 '17 at 00:52
  • A command like LIST VOC WITH F1="K" F1 F2 TOXML TO TEST ends up dumping an XML doc like ..., which is not too bad to parse in Unibasic. XDOMTransform looks a bit much for an XML beginner. – Ian McGowan Dec 05 '17 at 01:05