MarcusD Posted October 26, 2018 Posted October 26, 2018 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
FrancescoDiMuro Posted October 26, 2018 Posted October 26, 2018 Hi @Marcus Take a look at StringSplit(), _FileReadToArray(), and _FileCreate() functions in the Help file Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
MarcusD Posted October 26, 2018 Author Posted October 26, 2018 Hi Francesco, thanks for your reply - the main question is, how to check if there is a new invoice no or not. Marcus
FrancescoDiMuro Posted October 26, 2018 Posted October 26, 2018 @MarcusD It depends... How is it updated this file? Does it always have the same name? Where is/are stored the last information (invoice) ? Tell us more information, so we can see how we can help you Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
MarcusD Posted October 26, 2018 Author Posted October 26, 2018 Hi, i got the invoice (flat) file on a daily base and the structure of the file is fix. My question is, how is the best way to regonize a new invoice no . Marcus
FrancescoDiMuro Posted October 26, 2018 Posted October 26, 2018 @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: Forum Rules Forum Etiquette
MarcusD Posted October 26, 2018 Author Posted October 26, 2018 Hi, to store the last invoice no. is not necessary , that means i got every day a complete new file...
FrancescoDiMuro Posted October 26, 2018 Posted October 26, 2018 9 minutes ago, MarcusD said: that means i got every day a complete new file... So, your need is to... ? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Subz Posted October 26, 2018 Posted October 26, 2018 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
MarcusD Posted October 31, 2018 Author Posted October 31, 2018 Hi Subz, Thanks - very helpful ! MArcus
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now