| | |
how to get the difference between the data of the two files
![]() |
Your description is kind of vague. So, I'm going to make a couple of assumptions. Firstly, the two data files are similar in structure. I assume that the first data file has a key field that you can search for in the second data file. Secondly, I assume that having searched and found a record in the second data file where the key matches the key in the first file, that there is another column that you wish to compare in the two selected records.
I would load the records from the two data files into two tables, say tbl1 and tbl2.
Then do the following:
Dim db as Database
Dim rs1 as Recordset, rs2 as Recordset
.
.
.
Set rs1 = db.OpenRecordset("SELECT key, value FROM tbl1 WHERE key=" & keyvalue)
If Not rs1.BOF Then
Set rs2 = db.OperRecordset("SELECT key, value FROM tbl2 WHERE key=" & keyvalue)
If Not rs2.BOF then
if rs1.Fields("value") = rs2.Fields("value") then
MsgBox("Found matching record for " & rs2.Fields("value")
Else
MsgBox(rs1.Fields("value") & " in rs1 does not match " & rs2.Fields("value") & " in rs2!"
Else
MsgBox("No matching record in tbl2 for " & keyvalue)
Exit Sub
End If
Else
MsgBox("No matching record in tbl1 for " & keyvalue)
end If
End Sub
This is not a good technique if you have multiple keys you want to match, but I hope it gives you a sense of what you need to do.
Hoppy
I would load the records from the two data files into two tables, say tbl1 and tbl2.
Then do the following:
Dim db as Database
Dim rs1 as Recordset, rs2 as Recordset
.
.
.
Set rs1 = db.OpenRecordset("SELECT key, value FROM tbl1 WHERE key=" & keyvalue)
If Not rs1.BOF Then
Set rs2 = db.OperRecordset("SELECT key, value FROM tbl2 WHERE key=" & keyvalue)
If Not rs2.BOF then
if rs1.Fields("value") = rs2.Fields("value") then
MsgBox("Found matching record for " & rs2.Fields("value")
Else
MsgBox(rs1.Fields("value") & " in rs1 does not match " & rs2.Fields("value") & " in rs2!"
Else
MsgBox("No matching record in tbl2 for " & keyvalue)
Exit Sub
End If
Else
MsgBox("No matching record in tbl1 for " & keyvalue)
end If
End Sub
This is not a good technique if you have multiple keys you want to match, but I hope it gives you a sense of what you need to do.
Hoppy
Last edited by hopalongcassidy; Oct 15th, 2007 at 1:38 pm.
•
•
Join Date: Oct 2007
Posts: 13
Reputation:
Solved Threads: 0
i have to load the two files into the same table not in two different tables.
then i want to compare the following thing
say c1 is column1,c2 is column 2
r1 is row1 and r2 is row2
now the values in the table r like this
c1r1 c2r1(data from file 1)
c2r2 c2r2( data from file 2)
now i want to get the difference between c2r1 and c2r2
then i want to compare the following thing
say c1 is column1,c2 is column 2
r1 is row1 and r2 is row2
now the values in the table r like this
c1r1 c2r1(data from file 1)
c2r2 c2r2( data from file 2)
now i want to get the difference between c2r1 and c2r2
•
•
Join Date: Nov 2006
Posts: 30
Reputation:
Solved Threads: 4
rs.open "SELECT C2 FROM Table_Name"
C2R1 = rs("C2")
rs.MoveNext
C2R2 = rs("C2")
compare C2R1 and C2R2
Hope this helps.
C2R1 = rs("C2")
rs.MoveNext
C2R2 = rs("C2")
compare C2R1 and C2R2
Hope this helps.
www.easyprograming.com
Make Your Programing Easy
Make Your Programing Easy
Firstly, I don't think that yello's solution will work unless both files have exactly one row.
If you initially load both files into a single table, say by loading one file and then appending the second, you will not be able to tell whether two rows that match came from the two rows in the first file (with the same key), two rows from second file or one row from each.
If you want both files to end up in the same table, you can always combine the two tables after your search.
Hoppy
If you initially load both files into a single table, say by loading one file and then appending the second, you will not be able to tell whether two rows that match came from the two rows in the first file (with the same key), two rows from second file or one row from each.
If you want both files to end up in the same table, you can always combine the two tables after your search.
Hoppy
•
•
Join Date: Oct 2007
Posts: 13
Reputation:
Solved Threads: 0
i have two data files which contain the values to be stored into the columns of the table .
these files are of same nature ,i.e their data needs to be put into the same table.
these files have data for 6 columns.
now i want to compare the data of only two columns and want to get the difference between these two columns only.
if we can compare these two files and get the difference between two columns before loading them into the table , then that would also be fine.
can u guys help me out with its code..
these files are of same nature ,i.e their data needs to be put into the same table.
these files have data for 6 columns.
now i want to compare the data of only two columns and want to get the difference between these two columns only.
if we can compare these two files and get the difference between two columns before loading them into the table , then that would also be fine.
can u guys help me out with its code..
I'm still not quite sure I understand exactly what you are asking for, but I'm going to take a stab at it. Firstly, you need to realize that mysql or any other SQL does not operate on data files on your hard disc; only on tables or things that look like tables (queries) within a database. So, if you want to use mysql, you must first get the data into two tables, say tbl1 and tbl2.
Let's say that you have done that and both tbl1 and tbl2 each have two fields called "key" and "value", then try this query:
Hoppy
Let's say that you have done that and both tbl1 and tbl2 each have two fields called "key" and "value", then try this query:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
mysql_query("SELECT tbl1.key, (tbl1.value - tbl2.value) AS diff FROM tbl1 INNER JOIN tbl2 ON tbl1.key = tbl2.key")
Hoppy
Last edited by hopalongcassidy; Oct 18th, 2007 at 12:55 pm.
•
•
Join Date: Nov 2006
Posts: 30
Reputation:
Solved Threads: 4
I can suggest two methods that may work for you.
1. do some vbscripting to extract the required columns from both text files and save it as two files say file1.txt and file2.txt
Now run the 'diff' command to get the difference.
2. Create one more column in the database for storing some ID. While loading data from file 1 give the ID as F1. While loading data from file 2 give the ID as F2. Then write an sql query to get the values for both IDs seperately, sort it and compare it.
1. do some vbscripting to extract the required columns from both text files and save it as two files say file1.txt and file2.txt
Now run the 'diff' command to get the difference.
2. Create one more column in the database for storing some ID. While loading data from file 1 give the ID as F1. While loading data from file 2 give the ID as F2. Then write an sql query to get the values for both IDs seperately, sort it and compare it.
www.easyprograming.com
Make Your Programing Easy
Make Your Programing Easy
![]() |
Similar Threads
- load bulk data files into mysql dynamically (Visual Basic 4 / 5 / 6)
- Writing mp3 files to data files (OS X)
- How do I work with data files? (C#)
- Who knows all Outlook 2000 data files? (Windows Software)
- Reformat harddrive, keep image of files? Norton Ghost?? (Storage)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: printer quality
- Next Thread: Vb6 Sql
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





