Unique, incrementing, sequence number in CSV Header

This topic contains 2 replies, has 2 voices, and was last updated by  BrizoH 1 year, 8 months ago.

  • Author
  • #55441


    Hi guys,

    New to the forum (and to Powershell if I'm honest)

    I have a problem I'm hoping someone can point me in the right direction to solve – I have to merge two CSV files, adding a header and trailer (which is fine), the resulting output CSV (named with date/time stamp) will then be sent to a supplier.

    This will be a daily task and as such the suppliers format specifies that a unique file transaction/sequence number is included in the header – basically 1 for the first file and so on. For the life of me I can't find out how to do this, referencing the previous sequence number and incrementing daily.

    Any tips or pointers would be greatly appreciated

    Thanks in advance

  • #55450

    Don Jones

    So, could you not store a starting value in a file?

    1 | Out-File lastvalue.txt

    And then...

    $lastvalue = [int](Get-Content lastvalue.text)
    $todaysvalue = $lastvalue++
    $todaysvalue | out-file lastvalue.txt


  • #55454


    I will give that a go and get back to you, thanks for the quick reply – great forum, I'm sure I'll be spending a lot of time here!

You must be logged in to reply to this topic.