Unique, incrementing, sequence number in CSV Header

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of BrizoH BrizoH 1 month, 2 weeks ago.

  • Author
    Posts
  • #55441
    Profile photo of BrizoH
    BrizoH
    Participant

    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
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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
    Profile photo of BrizoH
    BrizoH
    Participant

    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.