I have been working on and had help on creating a macro that compares two list and returns which numbers are different between the two lists.
With some help I got it working in an ideal setting in which both lists are simple TXT files with one number per row however in reality I will be comparing a Txt file with a csv file.
Here is the code thus far:
ReadFile>C:\Users\Preferred User\Desktop\View List.txt,List1
Separate>List1,CRLF,Array1
ReadFile>C:\Users\Preferred User\Desktop\0000258.csv,List2
Separate>List2,CRLF,Array2
//MidStr>Array2_%x%,5,7,ArrayMid
//Messagemodal>Array1_count
if>Array1_count=0,End
if>Array2_count=0,End
Let>k=4
Repeat>k
Let>k=k+1
Gosub>Search
If>Found=False
Let>A1=Array1_%k%
MessageModal>%A1% not found in list 2
Endif
Until>k=Array1_count
Label>End
SRT>Search
Let>Found=False
Let>x=6
Repeat>x
Let>x=x+1
Let>A2=Array2_%x%
MidStr>%A2%,14,7,ArrayMid
If>%ArrayMid%=Array1_%k%
Let>Found=True
Goto>Search_x
EndIF
Until>x,Array2_count
Label>Search_x
END>Search
I have to compare the Txt file with specific parts of the CSV file so what I have been trying to do is just catch the number using MidStr which works but comes up with an "Error in substring command"
I am not sure why there is an error if it seems to be working as I would like it to......
Substring Command Error
Moderators: JRL, Dorian (MJT support)
I think your hard coded numbers of 14 and 7 in the following command:
MidStr>%A2%,14,7,ArrayMid
Might be invalid depending upon what the data looks like.
Try using the Length> command to make some comparisons
and be sure that you are not referencing positions in the string
which don't exist..... like maybe the string in the above example
is only 13 characters long, so starting in the 14th position is invalid?
Can you post samples of your data files if the above hint doesn't solve the problem?
MidStr>%A2%,14,7,ArrayMid
Might be invalid depending upon what the data looks like.
Try using the Length> command to make some comparisons
and be sure that you are not referencing positions in the string
which don't exist..... like maybe the string in the above example
is only 13 characters long, so starting in the 14th position is invalid?
Can you post samples of your data files if the above hint doesn't solve the problem?
-
- Newbie
- Posts: 10
- Joined: Fri Apr 30, 2010 3:10 pm
I'll try looking into that more.
The CSV file is the following:
________________________________________________________________
Invoice Number,ARCRX_0000258
Invoice Date,"04/08/2010 09:18AM"
Customer Name,"Jim Hugh"
Customer Firm,"S.R.W. Architecture, Inc."
Product ID (View Name),Detail ID,Detail Type, Title on Sheet, Detail Code
="0000756",="0000647",Foundation Detail
="0007461",="0007676",Roof Detail
="0010550",="0013565",Roof Detail
______________________________________________________________
I am not sure how that will read out in the forum but the Red numbers are the numbers that I am trying to compare. I have "Let>x=6" to begin looking through the numbers at the 6th line. (the X+1 then makes it begin at the 7th line I suppose)
The three lines should all be organized the same but I may be overlooking some specifics.
The CSV file is the following:
________________________________________________________________
Invoice Number,ARCRX_0000258
Invoice Date,"04/08/2010 09:18AM"
Customer Name,"Jim Hugh"
Customer Firm,"S.R.W. Architecture, Inc."
Product ID (View Name),Detail ID,Detail Type, Title on Sheet, Detail Code
="0000756",="0000647",Foundation Detail
="0007461",="0007676",Roof Detail
="0010550",="0013565",Roof Detail
______________________________________________________________
I am not sure how that will read out in the forum but the Red numbers are the numbers that I am trying to compare. I have "Let>x=6" to begin looking through the numbers at the 6th line. (the X+1 then makes it begin at the 7th line I suppose)
The three lines should all be organized the same but I may be overlooking some specifics.
check with length before doing a midstr function
Something like this perphaps? I think your csv file possibly has a blank line at the end, or just an extra CRLF. So this should check for that condition
[code]
Let>A2=Array2_%x%
Length>A2,A2_Length
If>A2_Length>20
MidStr>%A2%,14,7,ArrayMid
If>%ArrayMid%=Array1_%k%
Let>Found=True
Goto>Search_x
Endif
Endif
[/code]
[code]
Let>A2=Array2_%x%
Length>A2,A2_Length
If>A2_Length>20
MidStr>%A2%,14,7,ArrayMid
If>%ArrayMid%=Array1_%k%
Let>Found=True
Goto>Search_x
Endif
Endif
[/code]