Specify and process a file name with today’s date

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Specify and process a file name with today’s date

  • Creator
    Topic
  • #54806
    Rick Pritchett
    Participant

      I would like to be able to specify and process a file name with today’s date using either fileset/local or file.

      Ex:

    Viewing 9 reply threads
    • Author
      Replies
      • #83076
        Charlie Bursell
        Participant

          Take a look at the example: $HCIROOT/contrib/fileset_numfile_out.tcl

          It should be easy to modify to do what you want

          Be careful when using a datetime stamp as part of the file name.  Cloverleaf can easily process more than one message per second and you will lose messages by overwriting previous ones.  Consider using the datetime stamp along with a counter.  

          Cloverleaf is a “store and forward” engine. It has no knowledge of what came before and what is coming after.  Therefore it would have no knowledge of a previously processed message once delivered.

        • #83077
          Rick Pritchett
          Participant

            Is there a way to change the INBOUND filename so the it picks up a different file to process by name?  The name would have a date in it that would change.

          • #83078
            Charlie Bursell
            Participant

              Look at fileset_dir_parse.tcl in the contrib directory.  You can choose whatever files you want

            • #83079
              Robert Kersemakers
              Participant

                Hi Rick,

                If you want to determine which inbound files you want to process, you do this via ‘Directory Parse’: with a tcl-script you can determine yourself which files you want to process. By default all files are processed, so all filenames are included in xlateOutVals of Directory Parse. By only including certain filenames in xlateOutVals, only these files will be processed.

                Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

              • #83080
                Rick Pritchett
                Participant

                  I have tried a few different ways.  Here is what I have gotten to and the script does not pick up my file.  Any ideas?

                  #                

                  proc tps_fileset_dir_parse { args } {

                     global HciConnName                             ;# Name of thread

                     

                     keylget args MODE mode                         ;# Fetch mode

                     set ctx “”   ; keylget args CONTEXT ctx        ;# Fetch tps caller context

                     set uargs {} ; keylget args ARGS uargs         ;# Fetch user-supplied args

                     set debug 0  ;                                 ;# Fetch user argument DEBUG and

                     catch {keylget uargs DEBUG debug}              ;# assume uargs is a keyed list

                     set module “tps_fileset_dir_parse/$HciConnName/$ctx” ;# Use this before every echo/puts,

                                                                    ;# it describes where the text came from

                     set dispList {}                                ;# Nothing to return

                     switch -exact — $mode {

                         start {

                             # Perform special init functions

                             # N.B.: there may or may not be a MSGID key in args

                             

                             if { $debug } {

                                 puts stdout “$module: Starting in debug mode…”

                             }

                         }

                         run {

                             # ‘run’ mode always has a MSGID; fetch and process it

                             

                             keylget args MSGID mh

                   set filespec *.*; keylget args ARGS.FILESPEC filespec

                   set file_list [msgget $mh]

                              echo $file_list

                             set date [clock format [clock scan now] -format %Y%m%d]

                   

                             append my_filename Rick_file $date .csv

                             set outList {}

                             

                                 lappend outList $my_filename

                  echo outList $outList

                             echo $mh

                             msgset $mh $outList

                             lappend displist “CONTINUE $mh”

                         }

                         time {

                             # Timer-based processing

                             # N.B.: there may or may not be a MSGID key in args

                             

                         }

                         

                         shutdown {

                             # Doing some clean-up work

                             

                         }

                         

                         default {

                             error “Unknown mode ‘$mode’ in $module”

                         }

                     }

                     return $dispList

                  }

                • #83081
                  Robert Kersemakers
                  Participant

                    What doesn’t work Rick? At first glance your tcl-script looks ok. What do your echo commands show?

                    Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

                  • #83082
                    Charlie Bursell
                    Participant

                      Huh?  What are you trying to do here?

                      You get the list of input file canidates in the file_list variable then you do nothing with it.  You create a variable named my_filename that looks like:    “Rick_file20150901.csv”  You then assign that variable to a list, outlist, and return that.

                      You cannot create filenames here.  You are given a list of files the engine proposes to process and the order it will process them.  You are to return a list telling the engine which files to process and the order in which to process.

                      It cannot process a file name that is made up.

                      It may be better if you were to tell us in definitive terms what you are trying to do.  At this point I am not sure if you are trying to input or output files.

                    • #83083
                      Rick Pritchett
                      Participant

                        Thanks guys with your help it is now grabbing only the file I am specifying in the script.

                      • #83084
                        Rick Pritchett
                        Participant

                          Here is what I finally got to work for me.

                        • #83085
                          Jim Kosloskey
                          Participant

                            If you are looking for extended information in the File List your code definitely need to change – it may also need to change for a simple list as they have gone to keyed list (6.0.0 is even more different).

                            email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                        Viewing 9 reply threads
                        • The forum ‘Cloverleaf’ is closed to new topics and replies.