Hi David.
We process a CSV results file and translate to XML. I’ll highlight how we process this to give you an idea.
We use the csv package as Charlie advises and for processing and split the file and then process this big list to produce a list of lists, with each list being one record. Some of the data is text with newlines, so we don’t know easily the end of record!
To assist in loading into XML, we have a keydlist, with the csv ‘cell’ number and XML variable
eg
keylset myWpaList 0 SourceTypeCode
1 SourceEstablishmentCode
2 SourceRefNum
…
To load the XML (we use grm). we use the ‘info procs’ a lot so a translation procedure can just be added.
foreach myId [keylkeys myWpaList] {
set myVal [lindex $myList $myId]
#Print GlobPNT$HciConnName “List Id $myId [$myVal]” I
#
# Check for a conversion – currently on date/datetime
#
if {[info procs Xlate$myId] != {} } {
set myVal [Xlate$myId $myVal]
}
#
# the CSV split ends up with the odd ‘”‘ in a field. Using the
# -alternate switch skips fields!
# We load up data if it is NOT blank or ‘”‘.
#
if {!($myVal == {} || [string equal $myVal “])} {
grmstore $myXml ${myPtr}[keylget myWpaList $myId].#text c $myVal
}
}