CSV to fields from another program Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sebacote
Posts: 2
Joined: 17 May 2018, 13:34

CSV to fields from another program

17 May 2018, 13:44

Hi

I've used AHK in the past for some clicking, copy paste, windows switching, etc. but it's the first time I use it to read data from a file.

I have a file of names,numbers,email (1 line per person, infos separated by commas) in CSV (I also have it in XLS if it's easier that way).
I also have another program who has fields (A name field, A Last name field, email field, etc.).

I want to use AHK to make it press the "New" button, then the window with fields open, then it reads the first line from the CSV, write the correct infos in each fields, then press Save.
Rince and repeat for the other lines in the CSV.

I'm not quite good at programming, and I've searched this forum and the archive forum without any successful info for me.

Is someone here can help me?

Thanks!
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: CSV to fields from another program

17 May 2018, 14:06

Can you please post any code you've already tried and also an example of the CSV file?
Thanks
sebacote
Posts: 2
Joined: 17 May 2018, 13:34

Re: CSV to fields from another program

17 May 2018, 14:28

TLM wrote:Can you please post any code you've already tried and also an example of the CSV file?
Thanks
I don't have any code right now as I don't know where to start. I have the file in a plain Excel format, and also converted it in CSV. I can also use Excel to read cells if it's more easy.

I can't also show my CSV as it is sensible info, but I'll paste a sample with false data :

Code: Select all

F1,2131,[email protected],John Doe
F1,55311,[email protected],Jane Doe 
F2,7332,[email protected],John Smith
F3,23451,[email protected],Jane Smith
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: CSV to fields from another program  Topic is solved

17 May 2018, 15:03

This should be fairly easy to do with two loops, a file read loop and a CSV parse loop. Here is an example:

Code: Select all

FileSelectFile, FilePath

Loop, Read, %FilePath%
{
	;Any code that needs to be executed for each line of the CSV file goes here
	Loop, Parse, A_LoopReadLine, CSV
	{
		;Inside this loop, the variable A_LoopField contains the value of the current field in the CSV file
		;For example, it will contain F1 the first time, then 2131, then [email protected], then John Doe
		;After that, the outer loop will move to the next line of the CSV file
		;You can use the variable A_Index to count which loop you are on. For example:
		if (A_Index = 1)
		{
			;What to do with the first column goes here
		}
		else if (A_Index = 2)
		{
			;What to do with the second column goes here
		}
	}
}
mgroen
Posts: 97
Joined: 13 Jul 2018, 02:22

Re: CSV to fields from another program

18 Jul 2018, 08:39

I am struggling with the same. How can use the code as displayed above?
I mean where to define the file name?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, iamMG, Theda and 169 guests