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:

INVNo|ProductName|Description|PRICE

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 !

 

Marcus

 

Link to post
Share on other sites

@MarcusD
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:

Spoiler

ALWAYS GOOD TO READ:

 

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)
Next

 

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...