Jump to content

CSV to Webform


Recommended Posts

Good morning,

Apologies if this thread already exists or I've completely missed the answer in a similar thread. 

I'm new to Autoit since yesterday, albeit that I've had an account for 3 years, I'm only starting to get into it. I am trying to create a script which will read my CSV row by row and create a variable per cell on that row. In my job I'm going to need to fill out a webform 100 times over so I would like to input each variable into my chosen field on this webform and repeat.

I've been playing with AutoIT and this is what I've done so far, am I on the right track? I was thinking of using the StringSplit functions but I am a bit clueless to be honest. Any help would be Great to get me started.

#include <file.au3>
#include <FileConstants.au3>
#include <array.au3>

_BrowseForFile()

Global $aOutput, $FilePath

_FileReadToArray ($FilePath,$aOutput,4,",")
_ArrayDisplay($aOutput)

Func _BrowseForFile() ;Sets $FilePath
    global $FilePath=FileOpenDialog("Browse for CSV",@DesktopDir,"csv files (*.csv)",$FD_MULTISELECT + $FD_FILEMUSTEXIST)
EndFunc

 

Edited by Churchy112
Link to comment
Share on other sites

Yes, I think you are on the right track.
I suggest to drop function _BrowseForFile as a single line function is a lot of overhead.
As _FileReadToArray can handle CSV files now you've got a 2D array.
You would then need two loops to process each line (outer loop) and each cell in the row (inner loop).

Which browser do you use to fill the web form?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks for your suggestions.

I'll be using Chrome but I can switch to any if more compatible. I'm hoping to apply this to other uses such as iTunes account creation. I work with schools and for every Apple device in school I need to create an Apple ID for it, so thats on average 60 Apple IDs per school :(.

Would you mind giving me a example of the loops that I could have a play with?

Link to comment
Share on other sites

I'm not sure you need two loops because I assume you process all fields of a reacord (row) and write them to a single web page.
So it could look like:

For $i = 1 to $aOutput[0][0]
    ; Write the first field to the web page: $aOutput[$i][0]
    ; Write the second field to the web page: $aOutput[$i][1]
    ; ...
Next

How to write the data to the web page depends on the browser you use. Easiest is IE (a UDF comes with AutoIt), more complex gets FF etc.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I'm not sure you need two loops because I assume you process all fields of a reacord (row) and write them to a single web page.
So it could look like:

For $i = 1 to $aOutput[0][0]
    ; Write the first field to the web page: $aOutput[$i][0]
    ; Write the second field to the web page: $aOutput[$i][1]
    ; ...
Next

How to write the data to the web page depends on the browser you use. Easiest is IE (a UDF comes with AutoIt), more complex gets FF etc.

Thanks! I just need to have a play at the emulation functions and I'll give it a go tomorrow with iTunes form at my school. 

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

×
×
  • Create New...