Classic file types are no longer available for use as of January 2021. You can transition your classic files or download a PDF. Learn More

How to get number of files in SFTP listing?

Answered

Comments

7 comments

  • Jeff Hickey

    Hi Waldo, since you have transformed the data into a CSV, you could use the Advance Query command with the PRAGMA statement to get the table_info(). This will include the record count of the data.

    0
  • Waldo Nell

    Ok and if I do not convert it?  How do I ask a JSON array its length?  That would be even simpler.

    0
  • Jeff Hickey

    I don't think it would be simpler in Chains. I imagine you would need to do something a little more tricky like iterate over it to capture a count or split it into chunks. The simplest way that I am aware of is to transform it to a CSV and then use Advanced Query.

    0
  • Waldo Nell

    Thanks Jeff.  Last question - why did my approach fail?  The Array to CSV failed as per above so I cannot implement your solution without moving beyond it.

    0
  • Jeff Hickey

    The output from the List Directory command will need to be modified a bit, otherwise the error you ran into will be hit. First, the List Directory output is almost in a useable CSV format expect for the leading and trailing brackets. After removing the brackets, the data can be queried in Advanced Query. So the steps are to use Create File with the output from List Directory, then two instances of Find and Replace to remove the opening and closing brackets from the Create File output. The resulting file (which should now contain "/FILEA-2021.csv","/FILEB-6361152.csv" given your example as original input) can then be passed into the Advanced Query command as mentioned above to get the row count.

    1
  • Waldo Nell

    I am not convinced that would work.  I ended up doing below which does.  Unless you implied I do some kind of transpose query in Advance Query as I would need to then count the number of columns as you have not transposed the data.  My solution based on yours below for anyone needing to do something similar:

    0
  • Jeff Hickey

    Historically, I haven't ran into a case requiring a transpose. But glad you were able to get a working solution. 

    0

Please sign in to leave a comment.