Sign in to follow this  
Followers 0
evaluser

Importing csv file & its fields

6 posts in this topic

Hi,

Could u plz let me know a sample snippet for importing a csv file in the autoit script editor & its fields from the csv file ?

Thanks.

Share this post


Link to post
Share on other sites



Hi,

Could u plz let me know a sample snippet for importing a csv file in the autoit script editor & its fields from the csv file ?

Thanks.

You need to be much more specific in your needs, what you've attempted, and where you're failing at.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Hi.

Could u plz let me know a sample snippet for importing a csv file in the autoit script editor & its fields from the csv file ?

Please read the sample snippets in the help file:

CSV files are organized in lines. --> filereadline()

In each line the fields are separated by a certain CHAR. --> stringsplit()

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

The sample scenario is

- Open csv file

- Access username & password field values (file attached in txt format)

- Pass the field values(username & password) to the respective GUI components(text boxes) in the application using the Send function

Sample script created below

$file=FileOpen("C:\inputdata.csv",0)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; How can i access the field values & pass it in send() function

FileClose($file)

inputdata.txt

Share this post


Link to post
Share on other sites

The sample scenario is

- Open csv file

- Access username & password field values (file attached in txt format)

- Pass the field values(username & password) to the respective GUI components(text boxes) in the application using the Send function

Sample script created below

$file=FileOpen("C:\inputdata.csv",0)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; How can i access the field values & pass it in send() function

FileClose($file)

_FileReadToArray() will return an array of file lines

StringSplit() can split that value to give you the rest.

However, if your csv file is that simple...

#include <array.au3>; So you can see output
Global $s_file = @HomeDrive & "\inputdata.csv"
Global $s_read = FileRead($s_file)
Global $a_user_pass = StringRegExp($s_read, "(?i)username,passwd.*?\v+(.+?),(.+?)(?:\v|\z)", 3)
_ArrayDisplay($a_user_pass)

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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