Jump to content
Macro Express Forums

How to loop macro & have ASCII reference the subsequent line in csv file

Recommended Posts

Hi everyone,


This is my first time using Macro Express and I'm slowing starting to get the hang of it...I think. I'm trying to make a macro that opens a website, pulls the first value from a csv file, then enters more variables from the first line before looping back to search for the second value, etc.


So far I've managed to get the macro to execute everything correctly for the first line, now I'm not sure how to get it to repeat the process, reference the next line and then stop the macro after all the records are entered. until the end of the csv file.


 Does anyone know how to help? :S 


I've attached a copy of my macro for reference.


Link to comment
Share on other sites

Hi Cory,


I know I would repeat the ASCII File Process section but I'm not sure how to get it so that once it completes the loop it moves on to the next line of data in the csv file :(


I'm also not sure if there are specific repeat settings I should use that would help with this

Link to comment
Share on other sites

Every iteration of the command reads in another line of data. All the elements in that line are put into an array variable you will use to do your iterative process. 

Link to comment
Share on other sites

"The ASCII File Process is a powerful command that extracts data from text files, one line at a time. The values of each record are saved to variables for later use, such as inserting the extracted values into other applications. This is an efficient method for transferring data from one file to another." - Help

Might be a problem with your data file. Post a sample and I'll check it for you quick. 

Link to comment
Share on other sites


Modria Geico Automated List - Copy - Copy.csv


The macro enters the value from column A into the website and then performs some functions before inputting the values from columns B C D E F G H into their appropriate fields. Once the ASCII Process reaches the last function it should move to line 2 of the csv file and do it all over again but it doesn't pull the value of cell A2 and instead repeats the data from A1

Link to comment
Share on other sites

00000000h: EF BB BF 31 2C 44 61 77 6E 2C 41 2C 35 31 36 33 ; 1,Dawn,A,5163
00000010h: 35 35 39 36 39 36 2C 24 31 33 31 2E 30 35 20 2C ; 559696,$131.05 ,
00000020h: 30 2C 24 34 30 2E 30 30 20 2C 24 32 36 2E 32 31 ; 0,$40.00 ,$26.21
00000030h: 20 0D 0A 32 2C 44 61 77 6E 2C 41 2C 35 31 36 33 ;  ..2,Dawn,A,5163
00000040h: 35 35 39 36 39 36 2C 22 24 32 2C 39 33 33 2E 37 ; 559696,"$2,933.7
00000050h: 34 20 22 2C 30 2C 24 34 30 2E 30 30 20 2C 24 35 ; 4 ",0,$40.00 ,$5
00000060h: 38 36 2E 37 35 20 0D 0A                         ; 86.75 ..

This is the Hex view showing all the bytes. Decoded characters at the right. This is not an ASCII file, it's UTF-8 with a BOM. See those three bytes () at the beginning? That's the BOM (byte order marker). You need to either save this as UTF-8 without BOM or ASCII/ANSI. I'm guessing you used Notepad, which used to be pure ASCII but a few years ago was upgraded to do UTF-8-BOM as default. I'm going to ask ISS to update MEP to handle UTF-8 with BOM. BTW, MEP doesn't do Unicode. 
I also noticed that you have trailing spaces in many columns, E.G. "$131.05 ,". See the space between the five and the comma?
Best to fix these in your source, but if not, you can delete the first three characters of the file in MEP and save. And you can use a trim command on the others with the trailing spaces. 

If you save the file correctly, does it work?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...