Jump to content

Open File


Recommended Posts

I apoligize for this question but I do not feel as the API page. Has give me enough information.

I am trying to open a file in the current directory of my Script. But every time I do open it I get a blank file.

The error message box does not open.and when it gets to reading the CSV file I get nothing. am I doing something wrong?

#include"_CSVLib.au3"
#include <Array.au3>
$file = FileRead(@ScriptDir & "\DoctorMaping.csv")
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
$Records = _CSVGetRecords ($file, -1, -1, 0)
_ArrayDisplay($Records, 'Information.')

I have also tried

FileOpen(@ScriptDir & "\DoctorMaping.csv",0)
Link to comment
Share on other sites

#include"_CSVLib.au3"

#include <Array.au3>

$file = FileRead(@ScriptDir & "\DoctorMaping.csv")
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
ConsoleWrite ( "$file : " & $file & @Crlf )

what does the console returns ?

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Not having the faintest clue as to what _CSVLib.au3 contains and what _CSVGetRecords exactly expects and does, doesn't help us much to help you.

Since the file is successfully read, the issue is with the above-mentionned function rather than with opening the file.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

am I doing something wrong?

I searched for the thread and downloaded the file and, yes you are doing something wrong. Not reading the documentation (in this case the function header).

You give the $pFullPath param some file data when you are told:

$pFullPath  -   Path and filename of the csv file.

Also, look at the actual code, it's just doing a FileOpen() on $pFullPath, how do you expect FileOpen() to work on a the contents of the csv file? :huh2:

Also2:

;                   On Failure  -   $lRecords[0] = 0 and sets @error = 1 if open or read error
;                               -   $lRecords[0] = 0 and sets @error = 2 if no records found.

Checking @error might have given you a clue ;)

Also3:

Look at the code again. It never FileClose()'s the handle, so if you repeatedly uses the function you'll be unable to Open files eventually. Fix it yourself or download the updated _CSVLib_V1.3.au3

Also4:

You might want to post a link next time you ask about a more exotic udf, less "wtf is _CSVLib.au3" -posts then :alien:

Link to comment
Share on other sites

Also4:

You might want to post a link next time you ask about a more exotic udf, less "wtf is _CSVLib.au3" -posts then :huh2:

Thank you very much for your assistance. I did not realize that it was the CSVLib that was messing up, or I would have posted a link. Actually I might even have caught the error my self.

This post is very helpful to me on using files with autoit.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...