lsakizada Posted December 6, 2017 Posted December 6, 2017 Hi All, I have not visiting you for long time, happy to be here again !!!! I need help, I have a file that it is fails to opened with _FileReadToArray() function. It returns error 1 ("Error opening specified file"). BTW: For general info, the file is created on Amazon S3 and I downloaded it to my windows PC (win 7) Any other application other then autoit script is opening it properly without any issue. Not all files from S3 has that problem and this is raise some concern for me that something is wrong with autoit. Can you please help to investigate it?. I attached an example such "problematic" file. Here is the code how I call to open the file. Func _GetTestNameFromResultsFile($ResultsFile) Local $i, $arrContent, $arrLine, $res = 0 Local $delim = ",", $aRet $res = _FileReadToArray($ResultsFile, $arrContent) If $res = 1 Then ;succes For $i = 1 To 1 $arrLine = StringSplit($arrContent[$i], $delim) If IsArray($arrLine) And $arrLine[0] <> 0 Then $aRet = StringSplit($arrLine[1], '/') Return $aRet[4] Else _Log_Report($hLog, "_GetTestNameFromResultsFile: Error splitting first line!", 5) SetError(2) EndIf Next Else _Log_Report($hLog, "_GetTestNameFromResultsFile: Error opening file for reading test name! " & "error:" & @error, 5) SetError(1) EndIf EndFunc ;==>_GetTestNameFromResultsFile all_clips_results.csv Be Green Now or Never (BGNN)!
mikell Posted December 6, 2017 Posted December 6, 2017 This works for me. Check your code ^^ #Include <Array.au3> #Include <File.au3> Local $arrContent _FileReadToArray("all_clips_results.csv", $arrContent) _ArrayDisplay($arrContent)
SlackerAl Posted December 7, 2017 Posted December 7, 2017 Random guess... are you copying/downloading that file with the same script and accidentally trying to open it whilst it is still being copied and has a file lock on it? Does anything else have write access to it that is causing a file protection event of some kind? Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.
SlackerAl Posted December 7, 2017 Posted December 7, 2017 (edited) I made the small amount of effort required to turn that into a self-contained, running replicator. #include <File.au3> Global $sReturnedValue = _GetTestNameFromResultsFile("all_clips_results.csv") MsgBox(0, "Log", $sReturnedValue) Func _GetTestNameFromResultsFile($ResultsFile) Local $i, $arrContent, $arrLine, $res = 0 Local $delim = ",", $aRet $res = _FileReadToArray($ResultsFile, $arrContent) If $res = 1 Then ;success For $i = 1 To 1 $arrLine = StringSplit($arrContent[$i], $delim) If IsArray($arrLine) And $arrLine[0] <> 0 Then $aRet = StringSplit($arrLine[1], '/') Return $aRet[4] Else MsgBox(0, "Log", "_GetTestNameFromResultsFile: Error splitting first line!") SetError(2) EndIf Next Else MsgBox(0, "Log", "_GetTestNameFromResultsFile: Error opening file for reading test name! ") SetError(1) EndIf EndFunc ;==>_GetTestNameFromResultsFile And using your supplied test data it reads the file and returns some data. Edited December 7, 2017 by SlackerAl Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.
lsakizada Posted December 7, 2017 Author Posted December 7, 2017 (edited) On 12/7/2017 at 8:36 AM, SlackerAl said: Random guess... are you copying/downloading that file with the same script and accidentally trying to open it whilst it is still being copied and has a file lock on it? Does anything else have write access to it that is causing a file protection event of some kind? Expand Thanks Edit: found bug in my code. thanks for the help. Edited December 7, 2017 by lsakizada Be Green Now or Never (BGNN)!
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