Sign in to follow this  
Followers 0
notta

Is it just me?

5 posts in this topic

#1 ·  Posted (edited)

I have used this code a hundred times, but today it's not working. Am I missing something here? I have tried 2 machines with Autoit with the same result and different csv files. Before I posted I just created another file and put crap on the first line and $cline1 is still coming back empty. I have also restarted my machine. This is driving me crazy.

csv is in the format of name,room,model,....

The crap file I checked was just ksadjaskdjasd to see if it was even reading correctly, but came back empty as well.

#include <array.au3>


$fOpen1 = FileOpen("C:\machine1" & ".csv",1);and 0 for open mode
if $fOpen1 = -1 Then
    msgbox(0,"","File could not be opened")
    Exit
Else
    msgbox(0,"","File Exists");testing works every time
EndIf

FileClose($fOpen1)

$cline1 = FileReadLine($fOpen1)
If @error = -1 Then Exit; Never get this error

MsgBox(0,"",$cline1); comes back empty every time
$s = StringSplit($cline1,",")

_ArrayDisplay($s,"Before"); $s[0] comes back as 2, but both are empty
Edited by notta

Share this post


Link to post
Share on other sites



I have used this code a hundred times, but today it's not working. Am I missing something here? I have tried 2 machines with Autoit with the same result and different csv files. Before I posted I just created another file and put crap on the first line and $cline1 is still coming back empty. I have also restarted my machine. This is driving me crazy.

csv is in the format of name,room,model,....

The crap file I checked was just ksadjaskdjasd to see if it was even reading correctly, but came back empty as well.

#include <array.au3>


$fOpen1 = FileOpen("C:\machine1" & ".csv",1);and 0 for open mode
if $fOpen1 = -1 Then
    msgbox(0,"","File could not be opened")
    Exit
Else
    msgbox(0,"","File Exists");testing works every time
EndIf

FileClose($fOpen1)

$cline1 = FileReadLine($fOpen1)
If @error = -1 Then Exit; Never get this error

MsgBox(0,"",$cline1); comes back empty every time
$s = StringSplit($cline1,",")

_ArrayDisplay($s,"Before"); $s[0] comes back as 2, but both are empty

If you close the file before you read from it then why are you surprised? I don't believe that you have used this code before with any success. Move the FileClose line to later in the script where you have finished with the file.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Also your opening in write-append not read.

#include <array.au3>

$fOpen1 = FileOpen('test.csv',0);and 0 for open mode
if $fOpen1 = -1 Then
    msgbox(0,"","File could not be opened")
    Exit
Else
    msgbox(0,"","File Exists");testing works every time
EndIf

$cline1 = FileReadLine($fOpen1,1)
If @error = -1 Then Exit; Never get this error

FileClose($fOpen1)

MsgBox(0,"",$cline1); comes back empty every time
$s = StringSplit($cline1,",")

_ArrayDisplay($s,"Before"); $s[0] comes back as 2, but both are empty

Share this post


Link to post
Share on other sites

Thanks for the response guys. My bad, I moved the FileClose in my testing and forgot to move it back, but even when it's at the end of the script I still receive a blank string for $cline. Just to humor me and I know this is as basic as it comes, but can you create a 1 line c:\1.csv file with junk on it and tell me if msgbox(0,""$cline) gives a value? Thanks.

I have tried 0,1,2 for the open mode with the same result.

Share this post


Link to post
Share on other sites

Thanks for the response guys. My bad, I moved the FileClose in my testing and forgot to move it back, but even when it's at the end of the script I still receive a blank string for $cline. Just to humor me and I know this is as basic as it comes, but can you create a 1 line c:\1.csv file with junk on it and tell me if msgbox(0,""$cline) gives a value? Thanks.

I have tried 0,1,2 for the open mode with the same result.

The code that I posted back I did test with a csv file. The first line of the file was 111,222,333. $cline resulted in 111,222,333 and the array was 3|111|222|333. Note: the code is only reading the first line.

Share this post


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
Sign in to follow this  
Followers 0