John-Paul Posted June 29, 2005 Share Posted June 29, 2005 Does anyone know the trick to saving an altered CSV file. I open a CSV file, then I click the sort button (in design phase at moment) and the array is sorted by date value or ListView ID. Once sorted I want to save the file in the newly sorted order, however the save only saves the original file and not the newly sorted file. Any ideas, don't want to create an alternative file or rename a file, just want to keep the same file name. Link to comment Share on other sites More sharing options...
ezzetabi Posted June 29, 2005 Share Posted June 29, 2005 (edited) Since it is a CSV file, why do not you just modify it using Autoit directly? You can load the whole file in a variant, split it at @LF (or @CR or @CRLF as needed) and sort that array. Just make a function that compare correctly the dates or the IDs and use a sorting function that compare lines using that function. E.g. Comparing function for dates in the fourth field of a CSV array... #include <date.au3> Func _Before($sfst, $ssnd) Local $afst = StringSplit($sfst, ',') Local $asnd = StringSplit($ssnd, ',') $afst = $afst[4] $asnd = $asnd[4] $afst = StringSplit($afst, '/') $asnd = StringSplit($asnd, '/') Return _DateToDayValue($afst[1], $afst[2], $afst[3]) < _DateToDayValue($asnd[1], $asnd[2], $asnd[3]) EndFunc Edited June 29, 2005 by ezzetabi Link to comment Share on other sites More sharing options...
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