Sign in to follow this  
Followers 0
forum0member

How to read from and write to a csv file

9 posts in this topic

Hello,

I need a example how to call data from csv file and write to csv file.

Can you help me with an example script, please?

I am using: 

- Win 7

- AutoIt Version: 3.3.11.5 (Beta)

- FF.au3

- MozRepl Addon

Share this post


Link to post
Share on other sites



Have you bothered searching the forum? There are a number of posts dealing with csv files. If you are looking for something more detailed, then we need a more detailed description from you. Please give us an idea of the data and structure of the csv file (or attach a screenshot/example file), as well as what you have tried yourself. Help us help you :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Welcome to Autoit and the forum!

Do you have Excel installed on your computer?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you.

Yes, Excel 2010 is installed.

Share this post


Link to post
Share on other sites

An example for this:

This is how i fill form with imacros:

How is this possible with autoit?

VERSION  BUILD=7500718 RECORDER=FX
'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database
TAB T=1     
' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file
'CSV = Comma Separated Values in each line of the file
SET !DATASOURCE Address.csv

'SET !DATASOURCE_COLUMNS 8
'Start at line 2 to skip the header in the file
SET !LOOP 2
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}
' Fill web form   
URL GOTO=http://demo.imacros.net/Automate/AutoDataEntry
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:fname CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:lname CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:address CONTENT={{!COL3}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:city CONTENT={{!COL4}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:zip CONTENT={{!COL5}}
'
'Note * is used to ignore leading and trailing blanks that could be in the input data
'
'The precent (%) symbol is used to select the stateid by VALUE as defined in the website select statement and not by its index.
TAG POS=1 TYPE=SELECT FORM=ID:demo ATTR=NAME:state CONTENT=$*{{!COL6}}*
'
'The string ($) symbol is used to select the country by TEXT, not by its index.
'Index would be the position of an entry in the combo box list, e. g. 161 for United States
TAG POS=1 TYPE=SELECT FORM=ID:demo ATTR=NAME:country CONTENT=$*{{!COL7}}*
'
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:email CONTENT={{!COL8}}
TAG POS=1 TYPE=BUTTON:submit FORM=ID:demo ATTR=TXT:Submit

TAG POS=1 TYPE=A ATTR=TXT:*Back*

Share this post


Link to post
Share on other sites

If I understand you and the posted code correctly you try to read a CSV file line by line and insert the fields of each line into a web page?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

To read the content of a CSV file into an array I suggest to use this >UDF:

You can then loop through this array and send the data to the web page.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you very much water. This works great!

Share this post


Link to post
Share on other sites

Automating Firefox will be a bit harder ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

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