Jump to content

Split Text file by InvoiceNo

Recommended Posts

Good morning :)


I need you  help / advise. I got a flat CSV invoice file like:


17146330|PRODUCT A|Description|29.30
17146330|PRODUCT B|Description|50.30
17147635|PRODUCT B|Description|50.30
17147635|PRODUCT C|Description|100.00
17147698|PRODUCT D|Description|50.00
17147887|PRODUCT C|Description|100.00
17147887|PRODUCT D|Description|50.00
17149649|PRODUCT A|Description|29.30
17149649|PRODUCT A|Description|29.30

For each Invoice No i need a new CSV file - Do you have any idea how this might work?


Thanks for helping !




Link to post
Share on other sites

If the invoice is added at the end of the file, you could store somewhere the number of rows stored in the file, and with a timer, you could check if there are more rows than there were, your file has been updated.

This is a solution of many :)

Click here to see my signature:




Link to post
Share on other sites

You just need something like:

#include <Array.au3>
#include <File.au3>

Global $sTargetDir = @ScriptDir & "\Invoices"
    If FileExists($sTargetDir) = 0 Then DirCreate($sTargetDir)
Global $sSource = @ScriptDir & "\Flat.csv"
Global $aSource
_FileReadToArray($sSource, $aSource, 1, "|")
    If @error Then Exit
For $i = 1 To $aSource[0][0]
    FileWrite($sTargetDir & "\" & $aSource[$i][0] & ".csv", _ArrayToString($aSource, ",", $i, $i) & @CRLF)


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...