Jump to content
Sign in to follow this  
Churchy112

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

Share this post


Link to post
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 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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?

Share this post


Link to post
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 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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. 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Colduction
      Hello AutoIt Programmers, i was working on my project and i reffered to @KBLayout, @MUILang & @OSLang then i saw that code example of this macro is not too complete, i decided to share my customized _GetLanguage() for you:
      #include <MsgBoxConstants.au3> MsgBox($MB_SYSTEMMODAL, "", "The language of the OS is: " & _GetLanguage() & " (" & LCIDToLocaleName("0x" & @OSLang) & ")") ; Retrieve the language of the operating system. Func _GetLanguage() Switch @OSLang Case "0004" Return "Chinese - Simplified" Case "0401" Return "Arabic - Saudi Arabia" Case "0402" Return "Bulgarian - Bulgaria" Case "0403" Return "Catalan - Spain" Case "0404" Return "Chinese (Traditional) - Taiwan" Case "0405" Return "Czech - Czech Republic" Case "0406" Return "Danish - Denmark" Case "0407" Return "German - Germany" Case "0408" Return "Greek - Greece" Case "0409" Return "English - United States" Case "040A" Return "Spanish - Spain" Case "040B" Return "Finnish - Finland" Case "040C" Return "French - France" Case "040D" Return "Hebrew - Israel" Case "040E" Return "Hungarian - Hungary" Case "040F" Return "Icelandic - Iceland" Case "0410" Return "Italian - Italy" Case "0411" Return "Japanese - Japan" Case "0412" Return "Korean - Korea" Case "0413" Return "Dutch - Netherlands" Case "0414" Return "Norwegian (Bokmål) - Norway" Case "0415" Return "Polish - Poland" Case "0416" Return "Portuguese - Brazil" Case "0417" Return "Romansh - Switzerland" Case "0418" Return "Romanian - Romania" Case "0419" Return "Russian - Russia" Case "041A" Return "Croatian - Croatia" Case "041B" Return "Slovak - Slovakia" Case "041C" Return "Albanian - Albania" Case "041D" Return "Swedish - Sweden" Case "041E" Return "Thai - Thailand" Case "041F" Return "Turkish - Turkey" Case "0420" Return "Urdu - Pakistan" Case "0421" Return "Indonesian - Indonesia" Case "0422" Return "Ukrainian - Ukraine" Case "0423" Return "Belarusian - Belarus" Case "0424" Return "Slovenian - Slovenia" Case "0425" Return "Estonian - Estonia" Case "0426" Return "Latvian - Latvia" Case "0427" Return "Lithuanian - Lithuanian" Case "0428" Return "Tajik (Cyrillic) - Tajikistan" Case "0429" Return "Persian - Iran" Case "042A" Return "Vietnamese - Vietnam" Case "042B" Return "Armenian - Armenia" Case "042C" Return "Azeri (Latin) - Azerbaijan" Case "042D" Return "Basque - Basque" Case "042E" Return "Upper Sorbian - Germany" Case "042F" Return "Macedonian - Macedonia" Case "0432" Return "Setswana / Tswana - South Africa" Case "0434" Return "isiXhosa - South Africa" Case "0435" Return "isiZulu - South Africa" Case "0436" Return "Afrikaans - South Africa" Case "0437" Return "Georgian - Georgia" Case "0438" Return "Faroese - Faroe Islands" Case "0439" Return "Hindi - India" Case "043A" Return "Maltese - Malta" Case "043B" Return "Sami (Northern) - Norway" Case "043e" Return "Malay - Malaysia" Case "043F" Return "Kazakh - Kazakhstan" Case "0440" Return "Kyrgyz - Kyrgyzstan" Case "0441" Return "Swahili - Kenya" Case "0442" Return "Turkmen - Turkmenistan" Case "0443" Return "Uzbek (Latin) - Uzbekistan" Case "0444" Return "Tatar - Russia" Case "0445" Return "Bangla - Bangladesh" Case "0446" Return "Punjabi - India" Case "0447" Return "Gujarati - India" Case "0448" Return "Oriya - India" Case "0449" Return "Tamil - India" Case "044A" Return "Telugu - India" Case "044B" Return "Kannada - India" Case "044C" Return "Malayalam - India" Case "044D" Return "Assamese - India" Case "044E" Return "Marathi - India" Case "044F" Return "Sanskrit - India" Case "0450" Return "Mongolian (Cyrillic) - Mongolia" Case "0451" Return "Tibetan - China" Case "0452" Return "Welsh - United Kingdom" Case "0453" Return "Khmer - Cambodia" Case "0454" Return "Lao - Lao PDR" Case "0456" Return "Galician - Spain" Case "0457" Return "Konkani - India" Case "0459" Return "(reserved) - (reserved)" Case "045A" Return "Syriac - Syria" Case "045B" Return "Sinhala - Sri Lanka" Case "045C" Return "Cherokee - Cherokee" Case "045D" Return "Inuktitut (Canadian_Syllabics) - Canada" Case "045E" Return "Amharic - Ethiopia" Case "0461" Return "Nepali - Nepal" Case "0462" Return "Frisian - Netherlands" Case "0463" Return "Pashto - Afghanistan" Case "0464" Return "Filipino - Philippines" Case "0465" Return "Divehi - Maldives" Case "0468" Return "Hausa - Nigeria" Case "046A" Return "Yoruba - Nigeria" Case "046B" Return "Quechua - Bolivia" Case "046C" Return "Sesotho sa Leboa - South Africa" Case "046D" Return "Bashkir - Russia" Case "046E" Return "Luxembourgish - Luxembourg" Case "046F" Return "Greenlandic - Greenland" Case "0470" Return "Igbo - Nigeria" Case "0473" Return "Tigrinya - Ethiopia" Case "0475" Return "Hawiian - United States" Case "0478" Return "Yi - China" Case "047A" Return "Mapudungun - Chile" Case "047C" Return "Mohawk - Canada" Case "047E" Return "Breton - France" Case "0480" Return "Uyghur - China" Case "0481" Return "Maori - New Zealand" Case "0482" Return "Occitan - France" Case "0483" Return "Corsican - France" Case "0484" Return "Alsatian - France" Case "0485" Return "Sakha - Russia" Case "0486" Return "K'iche - Guatemala" Case "0487" Return "Kinyarwanda - Rwanda" Case "0488" Return "Wolof - Senegal" Case "048C" Return "Dari - Afghanistan" Case "0491" Return "Scottish Gaelic - United Kingdom" Case "0492" Return "Central Kurdish - Iraq" Case "0801" Return "Arabic - Iraq" Case "0803" Return "Valencian - Valencia" Case "0804" Return "Chinese (Simplified) - China" Case "0807" Return "German - Switzerland" Case "0809" Return "English - United Kingdom" Case "080A" Return "Spanish - Mexico" Case "080C" Return "French - Belgium" Case "0810" Return "Italian - Switzerland" Case "0813" Return "Dutch - Belgium" Case "0814" Return "Norwegian (Nynorsk) - Norway" Case "0816" Return "Portuguese - Portugal" Case "081A" Return "Serbian (Latin) - Serbia and Montenegro" Case "081D" Return "Swedish - Finland" Case "0820" Return "Urdu - (reserved)" Case "082C" Return "Azeri (Cyrillic) - Azerbaijan" Case "082E" Return "Lower Sorbian - Germany" Case "0832" Return "Setswana / Tswana - Botswana" Case "083B" Return "Sami (Northern) - Sweden" Case "083C" Return "Irish - Ireland" Case "083E" Return "Malay - Brunei Darassalam" Case "0843" Return "Uzbek (Cyrillic) - Uzbekistan" Case "0845" Return "Bangla - Bangladesh" Case "0846" Return "Punjabi - Pakistan" Case "0849" Return "Tamil - Sri Lanka" Case "0850" Return "Mongolian (Mong) - Mongolia" Case "0859" Return "Sindhi - Pakistan" Case "085D" Return "Inuktitut (Latin) - Canada" Case "085F" Return "Tamazight (Latin) - Algeria" Case "0867" Return "Pular - Senegal" Case "086B" Return "Quechua - Ecuador" Case "0873" Return "(reserved) - (reserved)" Case "0873" Return "Tigrinya - Eritrea" Case "0C01" Return "Arabic - Egypt" Case "0C04" Return "Chinese - Hong Kong SAR" Case "0C07" Return "German - Austria" Case "0C09" Return "English - Australia" Case "0C0A" Return "Spanish - Spain" Case "0C0C" Return "French - Canada" Case "0C1A" Return "Serbian (Cyrillic) - Serbia and Montenegro" Case "0C3B" Return "Sami (Northern) - Finland" Case "0C6B" Return "Quechua - Peru" Case "1001" Return "Arabic - Libya" Case "1004" Return "Chinese - Singapore" Case "1007" Return "German - Luxembourg" Case "1009" Return "English - Canada" Case "100A" Return "Spanish - Guatemala" Case "100C" Return "French - Switzerland" Case "101A" Return "Croatian (Latin) - Bosnia and Herzegovina" Case "103B" Return "Sami (Lule) - Norway" Case "105F" Return "Central Atlas Tamazight (Tifinagh) - Morocco" Case "1401" Return "Arabic - Algeria" Case "1404" Return "Chinese - Macao SAR" Case "1407" Return "German - Liechtenstein" Case "1409" Return "English - New Zealand" Case "140A" Return "Spanish - Costa Rica" Case "140C" Return "French - Luxembourg" Case "141A" Return "Bosnian (Latin) - Bosnia and Herzegovina" Case "143B" Return "Sami (Lule) - Sweden" Case "1801" Return "Arabic - Morocco" Case "1809" Return "English - Ireland" Case "180A" Return "Spanish - Panama" Case "180C" Return "French - Monaco" Case "181A" Return "Serbian (Latin) - Bosnia and Herzegovina" Case "183B" Return "Sami (Southern) - Norway" Case "1C01" Return "Arabic - Tunisia" Case "1c09" Return "English - South Africa" Case "1C0A" Return "Spanish - Dominican Republic" Case "1C1A" Return "Serbian (Cyrillic) - Bosnia and Herzegovina" Case "1C3B" Return "Sami (Southern) - Sweden" Case "2001" Return "Arabic - Oman" Case "2009" Return "English - Jamaica" Case "200A" Return "Spanish - Venezuela" Case "201A" Return "Bosnian (Cyrillic) - Bosnia and Herzegovina" Case "203B" Return "Sami (Skolt) - Finland" Case "2401" Return "Arabic - Yemen" Case "2409" Return "English - Caribbean" Case "240A" Return "Spanish - Colombia" Case "241A" Return "Serbian (Latin) - Serbia" Case "243B" Return "Sami (Inari) - Finland" Case "2801" Return "Arabic - Syria" Case "2809" Return "English - Belize" Case "280A" Return "Spanish - Peru" Case "281A" Return "Serbian (Cyrillic) - Serbia" Case "2C01" Return "Arabic - Jordan" Case "2C09" Return "English - Trinidad and Tobago" Case "2C0A" Return "Spanish - Argentina" Case "2C1A" Return "Serbian (Latin) - Montenegro" Case "3001" Return "Arabic - Lebanon" Case "3009" Return "English - Zimbabwe" Case "300A" Return "Spanish - Ecuador" Case "301A" Return "Serbian (Cyrillic) - Montenegro" Case "3401" Return "Arabic - Kuwait" Case "3409" Return "English - Philippines" Case "340A" Return "Spanish - Chile" Case "3801" Return "Arabic - U.A.E." Case "380A" Return "Spanish - Uruguay" Case "3C01" Return "Arabic - Bahrain" Case "3C0A" Return "Spanish - Paraguay" Case "4001" Return "Arabic - Qatar" Case "4009" Return "English - India" Case "400A" Return "Spanish - Bolivia" Case "4409" Return "English - Malaysia" Case "440A" Return "Spanish - El Salvador" Case "4809" Return "English - Singapore" Case "480A" Return "Spanish - Honduras" Case "4C0A" Return "Spanish - Nicaragua" Case "500A" Return "Spanish - Puerto Rico" Case "540A" Return "Spanish - United States" Case "7C04" Return "Chinese - Traditional" Case Else Return "Other (can't determine with @OSLang directly)" EndSwitch EndFunc ;==>_GetLanguage Func LCIDToLocaleName($iLCID) Local $aRet = DllCall("kernel32.dll", "int", "LCIDToLocaleName", "int", $iLCID, "wstr", "", "int", 85, "dword", 0) Return $aRet[2] EndFunc ;==>LCIDToLocaleName _GetLanguage.au3
      Source: AutoIt Help File (ScITE Editor (F1))

      I hope you enjoy this tiny code.
    • By adjist
      Hello all! 
       
      Getting this error :
      (22) : ==> Variable used without being declared.: if $vNumber = 0 Then if ^ ERROR  
      But I'm sure I have defined the variable, as in the top of my script has 
      Global $vNumber = 0  
      How would I go about fixing this?
       
    • By D2thunder
      Hi all, I wasnt active in this Forum forum for Years. 😅
      Since I need something with Json in AutoIt i write a little UDF to save a variable to file to read it with another language - and back. After a while until my other script grows i thought - lets integrate all variables wich is possible, because i want have arrays to.
      This is my first public UDF in Autoit - normaly my AutoIt scripts are quick an dirty.... - like the examples for this udf. - someone want to write nice examples?
      I tried to write this UDF properly, cared for processing speed, low mem consumption as possible, a short code, and a high usability without beeing very familiar with arrays.
      What is it for? - convert nearly all types of variables to a json string for saving it in a file or to an ini. Read it back in to a same formated variable and preserv variable types. All array types are supported with nested arrays, the only restriction is ram and array/stringsize - and time if the array is very big. You can use Filters for variable types and some other options.
      If anyone found a bug or any suggestions, please post it.
       
      get Json.au3 from here Json.au3
       
       
      JsonVar 2019.01.25.1.zip
    • By mlazovjp
      I am going through the AutoIt Wiki and soaking up a lot of great information.  On the “Best Coding Practices” page at https://www.autoitscript.com/wiki/Best_coding_practices#Scopes_of_Variables there seems to be a minor detail missing.  In the “Variable Initialization” section at https://www.autoitscript.com/wiki/Best_coding_practices#Variable_Initialization , there are references to a data type $o, but in the table listing prefixes and their data types, there does not appear to be a prefix “o”.  I assume that this is for Object?
    • By 3Jake
      Hello Smart People!
      I have a multi-column .CSV that I would like to draw information from, in order to populate (send) that info to some fields in an Oracle form.  This would be for account-creation in Oracle.

      I have the basic script to navigate (tab) through the fields in the Oracle form, but I am SUPER-new to AutoIT and don’t quite see how to get the script to import and use variables from a .CSV

      For example:

      My script just waits for the page to be active, then enters data and tabs between fields like this:

      ; Wait for the window to be active WinWaitActive("Oracle is Cool - E-Business is the Best") ; User Name Send("jsmith") Send("{TAB}") ; Password Send("Password1") Send("{TAB}") Send("Password1") Send("{TAB}") ; Description Send("John Smith") Send("{TAB}") (etc. etc. etc.…)

      The winning solution would take one row at a time, feed it into fields on the Oracle form, save, and then start in on the next row

      It looks like I’d need a combination of “FileReadToArray” ( or“FileReadLine”?) and “StringSplit” to loop through the values and set them to variables, which would then replace my current "hard-coded" values to be typed them into the form?

      I found the following example in the “Help” snippets for stringsplit()… this seems like it’s in the ballpark but I’m having some trouble wrapping this around what I’ve put together, since each entry in the array would have multiple elements per line instead of just “Day”:

      Func Example() Local $aDays = StringSplit("Mon,Tues,Wed,Thur,Fri,Sat,Sun", ",") ;Split the string of days using the delimiter "," and the default flag value. #cs The array returned will contain the following values: $aDays[1] = "Mon" $aDays[2] = "Tues" $aDays[3] = "Wed" ... $aDays[7] = "Sun" #ce For $i = 1 To $aDays[0] ; Loop through the array returned by StringSplit to display the individual values. MsgBox($MB_SYSTEMMODAL, "", "$aDays[" & $i & "] - " & $aDays[$i]) Next EndFunc ;==>Example

      This post also seems like a similar example, but I don’t need it to be so selective RE: one specific column:
      https://www.autoitscript.com/forum/topic/166261-how-to-read-csv-specific-row-and-columns


      Any advice would be appreciated!  Thanks for taking a minute to look!  
×
×
  • Create New...