I want to compare several HTML files which contains many string tags so I am looking for the best ways which have less time complexity .
For Example:
There are 2 HTML files below which contain many tags which are string so I want to compare them and count the similar tags at last by using these formulas:
1. Average of similar tags of each two HTML files = (Quantity of same tags in first file) + (Quantity of same tags in second file) / (Sum of all second column of first file) + (Sum of all second column of second file).
2. Main Function for calculating: F ( File1,File2 ) = ((Quantity of tags which are same in both files) / ( Quantity of all tags of first and second files - Quantity of tags which are same in both files ) ) * (Average of similar tags of each two HTML files)
counter: which has the quantity of similar tags of two HTML files.
Note: The second columns contain the quantity of each tag in current HTML file.
The first HTML file:
| joiuh | 12 |
| @62jj | 10 |
| k6235 | 2 |
| 99ui* | 3 |
| 00Qyu67 | 9 |
| *8455 | 7 |
The Second HTML File :
| 00Qyu67 | 20 |
| NY%%%20 | 1 |
| UWCN10 | 13 |
| 89PO* | 6 |
| $$CS40 | 11 |
| @62jj | 56 |
| k6235 | 10 |
In this example:
Average of similar tags of each two HTML files: ( ( 10 + 9 + 2 ) + ( 56 + 20 + 10 ) ) / ( ( 43 ) + ( 117 ) ) = 107 / 160 = 0.66
F ( File1,File2 ) = ( ( 3 ) / ( 13 - 3 ) ) * 0.66 = 0.198

Joe WilsonPosted Dec 29, 2014, 10:06 AM
VulpesPosted Dec 29, 2014, 6:56 AM
Joe WilsonPosted Dec 29, 2014, 6:01 AM
VulpesPosted Dec 28, 2014, 4:32 PM
If you make the highlighted alterations to the main function it will redirect to a file called output.txt which you can open with notepad and inspect at your leisure:
I have wondered before about using a hash-table approach but, if it does so at all, I doubt whether it will improve performance enough to be worth the effort of rewriting the program.
If you've managed to get the running time down to 6 to 10 minutes on an i7 machine I think that's a pretty good result :)
Joe WilsonPosted Dec 28, 2014, 2:45 PM
VulpesPosted Dec 28, 2014, 1:58 PM
To pause the screen, use this command:
system("pause");
Joe WilsonPosted Dec 28, 2014, 12:50 PM
VulpesPosted Dec 28, 2014, 12:04 PM
Joe WilsonPosted Dec 28, 2014, 11:51 AM
There isn't any other way to run the program, please help me.
VulpesPosted Dec 28, 2014, 10:54 AM
As mentioned earlier, by optimizing for speed, I managed to get the running time for these 8 files down to about 3 seconds on my i3 machine.
If there are 212 files altogether and the 8 used are fairly typical of these, then I would expect the total running time to be around 40 minutes. This is why I think it's important to test the program on a small number of files first.
Joe WilsonPosted Dec 28, 2014, 8:22 AM
VulpesPosted Dec 28, 2014, 7:08 AM
If you look at the program, the first thing it does is to load the contents of this file, so that it knows which individual .csv files to process.
An alternative to having this file would be to load ALL .csv files in the folder. However, this isn't a great idea from a testing point of view when (as here) there are a lot of files in the folder. You really want to test the program on just a few.
Joe WilsonPosted Dec 28, 2014, 3:25 AM
I think I have done what you have told before in order to solve the stopped working problem, but it didn't solve yet.
VulpesPosted Dec 27, 2014, 7:08 PM
So you need to create one. To start off I'd just list a few files in it rather than the whole lot so you can see that it is in fact working.
Joe WilsonPosted Dec 27, 2014, 3:55 PM
here is the txt file that I created
after creation of the program and exe file.
Volume in drive C is OS
Volume Serial Number is 703B-8275
Directory of C:\DS_Project
12/28/2014 12:16 AM
12/28/2014 12:16 AM
10/10/2014 01:55 AM 65,120 10072.csv
10/10/2014 01:55 AM 39,971 10105.csv
10/10/2014 01:55 AM 39,900 10107.csv
10/10/2014 01:55 AM 36,161 10108.csv
10/10/2014 01:55 AM 40,249 10128.csv
10/10/2014 02:26 AM 37,027 1014691.csv
10/10/2014 01:55 AM 38,399 10151.csv
10/10/2014 01:51 AM 42,781 1029.csv
10/10/2014 02:26 AM 44,605 1051327.csv
10/10/2014 01:51 AM 49,327 1060.csv
10/10/2014 02:07 AM 37,135 106587.csv
10/10/2014 02:27 AM 53,129 1116874.csv
10/10/2014 01:51 AM 86,725 113.csv
10/10/2014 02:27 AM 87,639 1133624.csv
10/10/2014 01:51 AM 86,791 115.csv
10/10/2014 02:27 AM 76,070 1182675.csv
10/10/2014 02:27 AM 39,201 1182694.csv
10/10/2014 02:27 AM 38,446 1182710.csv
10/10/2014 02:27 AM 42,466 1182718.csv
10/10/2014 02:27 AM 41,863 1182720.csv
10/10/2014 01:55 AM 53,123 11837.csv
10/10/2014 01:55 AM 40,228 11862.csv
10/10/2014 01:55 AM 62,113 11883.csv
10/10/2014 02:28 AM 55,459 1222607.csv
10/10/2014 01:55 AM 36,173 12349.csv
10/10/2014 01:55 AM 38,985 12466.csv
10/10/2014 01:55 AM 40,700 12491.csv
10/10/2014 02:29 AM 61,486 1386651.csv
10/10/2014 02:29 AM 51,629 1391550.csv
10/10/2014 01:56 AM 39,586 14710.csv
10/10/2014 01:52 AM 87,281 1472.csv
10/10/2014 01:51 AM 38,982 1473.csv
10/10/2014 01:51 AM 72,383 1477.csv
10/10/2014 01:52 AM 50,892 1479.csv
10/10/2014 01:51 AM 36,986 1495.csv
10/10/2014 01:51 AM 45,646 1500.csv
10/10/2014 01:51 AM 37,747 1507.csv
10/10/2014 01:51 AM 39,601 1512.csv
10/10/2014 01:51 AM 56,978 1525.csv
10/10/2014 01:52 AM 75,349 1526.csv
10/10/2014 01:51 AM 52,268 1527.csv
10/10/2014 01:51 AM 45,464 1534.csv
10/10/2014 01:51 AM 46,331 1537.csv
10/10/2014 01:52 AM 70,993 1538.csv
10/10/2014 02:30 AM 71,067 1541442.csv
10/10/2014 01:51 AM 49,081 1549.csv
10/10/2014 01:56 AM 60,831 15540.csv
10/10/2014 01:51 AM 36,901 1577.csv
10/10/2014 02:30 AM 47,709 1586826.csv
10/10/2014 01:51 AM 41,775 1588.csv
10/10/2014 01:52 AM 64,176 1590.csv
10/10/2014 01:52 AM 55,875 1638.csv
10/10/2014 01:51 AM 37,895 1653.csv
10/10/2014 02:30 AM 59,167 1667444.csv
10/10/2014 02:11 AM 36,202 167585.csv
10/10/2014 02:31 AM 42,843 1729243.csv
10/10/2014 02:12 AM 50,613 173670.csv
10/10/2014 01:51 AM 38,757 1748.csv
10/10/2014 02:31 AM 48,184 1769540.csv
10/10/2014 01:57 AM 56,634 17728.csv
10/10/2014 01:51 AM 65,045 1812.csv
10/10/2014 01:57 AM 47,471 19036.csv
10/10/2014 01:57 AM 40,771 19485.csv
10/10/2014 01:52 AM 67,220 1977.csv
10/10/2014 01:51 AM 36,267 1994.csv
10/10/2014 01:57 AM 46,516 20410.csv
10/10/2014 02:32 AM 37,925 2122992.csv
10/10/2014 01:52 AM 46,676 2150.csv
10/10/2014 01:52 AM 38,199 2152.csv
10/10/2014 01:52 AM 43,507 2182.csv
10/10/2014 01:52 AM 39,612 2184.csv
10/10/2014 01:52 AM 50,980 2199.csv
10/10/2014 01:52 AM 87,727 2204.csv
10/10/2014 01:52 AM 40,198 2215.csv
10/10/2014 01:52 AM 41,329 2225.csv
10/10/2014 01:52 AM 54,077 2228.csv
10/10/2014 01:52 AM 53,679 2236.csv
10/10/2014 01:52 AM 54,301 2264.csv
10/10/2014 02:32 AM 50,493 2280068.csv
10/10/2014 01:58 AM 38,483 22957.csv
10/10/2014 01:57 AM 37,411 22986.csv
10/10/2014 02:33 AM 63,195 2299193.csv
10/10/2014 01:58 AM 36,653 23107.csv
10/10/2014 01:52 AM 65,167 2340.csv
10/10/2014 01:52 AM 50,850 2348.csv
10/10/2014 02:33 AM 44,003 2449742.csv
10/10/2014 02:33 AM 65,696 2475502.csv
10/10/2014 02:33 AM 59,016 2480465.csv
10/10/2014 02:33 AM 51,763 2492277.csv
10/10/2014 01:52 AM 45,975 2567.csv
10/10/2014 01:52 AM 40,590 2575.csv
10/10/2014 01:58 AM 41,110 25918.csv
10/10/2014 02:33 AM 40,000 2619901.csv
10/10/2014 01:52 AM 48,070 2704.csv
10/10/2014 01:52 AM 49,412 2718.csv
10/10/2014 02:34 AM 87,387 2742161.csv
10/10/2014 02:34 AM 61,667 2770499.csv
10/10/2014 02:34 AM 57,196 2770555.csv
10/10/2014 02:34 AM 93,865 2773690.csv
10/10/2014 01:51 AM 41,750 283.csv
10/10/2014 01:59 AM 38,319 29144.csv
10/10/2014 01:52 AM 73,611 2930.csv
10/10/2014 01:59 AM 50,259 29374.csv
10/10/2014 01:52 AM 88,695 2964.csv
10/10/2014 02:34 AM 48,361 3032251.csv
10/10/2014 01:52 AM 47,170 3045.csv
10/10/2014 01:52 AM 57,904 3067.csv
10/10/2014 01:52 AM 92,429 3092.csv
10/10/2014 02:35 AM 72,195 3093889.csv
10/10/2014 02:35 AM 83,827 3123767.csv
10/10/2014 02:35 AM 41,473 3167566.csv
10/10/2014 02:35 AM 54,384 3181280.csv
10/10/2014 02:35 AM 42,270 3203319.csv
10/10/2014 02:35 AM 64,278 3203347.csv
10/10/2014 02:35 AM 57,652 3203350.csv
10/10/2014 02:35 AM 59,167 3203356.csv
10/10/2014 02:35 AM 84,261 3206242.csv
10/10/2014 01:52 AM 41,633 3207.csv
10/10/2014 01:52 AM 46,952 3253.csv
10/10/2014 01:52 AM 64,705 3261.csv
10/10/2014 01:52 AM 38,754 3359.csv
10/10/2014 01:52 AM 52,082 3373.csv
10/10/2014 01:59 AM 40,663 33867.csv
10/10/2014 01:59 AM 44,806 34878.csv
10/10/2014 02:35 AM 41,537 3488194.csv
10/10/2014 01:52 AM 37,203 3514.csv
10/10/2014 02:36 AM 92,542 3577382.csv
10/10/2014 01:51 AM 57,689 364.csv
10/10/2014 01:52 AM 36,106 3654.csv
10/10/2014 01:52 AM 47,356 3657.csv
10/10/2014 02:36 AM 36,540 3728592.csv
10/10/2014 02:36 AM 40,699 3745066.csv
10/10/2014 02:00 AM 40,514 39272.csv
10/10/2014 02:19 AM 74,246 393681.csv
10/10/2014 01:52 AM 36,701 3962.csv
10/10/2014 02:37 AM 47,930 4041453.csv
10/10/2014 01:53 AM 65,676 4044.csv
10/10/2014 02:37 AM 79,652 4053418.csv
10/10/2014 01:52 AM 41,230 4131.csv
10/10/2014 01:52 AM 39,795 4183.csv
10/10/2014 01:52 AM 67,278 4248.csv
10/10/2014 01:52 AM 40,748 4307.csv
10/10/2014 02:01 AM 40,294 43191.csv
10/10/2014 02:01 AM 38,024 44123.csv
10/10/2014 02:42 AM 44,683 4432994.csv
10/10/2014 02:42 AM 46,756 4479754.csv
10/10/2014 01:53 AM 46,577 4679.csv
10/10/2014 01:53 AM 37,333 4890.csv
10/10/2014 01:53 AM 38,372 4921.csv
10/10/2014 01:53 AM 50,773 4931.csv
10/10/2014 01:53 AM 41,815 4933.csv
10/10/2014 01:53 AM 35,792 4936.csv
10/10/2014 02:49 AM 38,426 4948864.csv
10/10/2014 02:50 AM 95,823 4979986.csv
10/10/2014 01:53 AM 59,070 5057.csv
10/10/2014 02:51 AM 37,300 5061284.csv
10/10/2014 01:53 AM 37,063 5068.csv
10/10/2014 02:51 AM 43,629 5072307.csv
10/10/2014 01:53 AM 39,538 5104.csv
10/10/2014 01:53 AM 39,585 5115.csv
10/10/2014 01:53 AM 57,185 5174.csv
10/10/2014 01:53 AM 39,069 5189.csv
10/10/2014 02:52 AM 66,140 5197633.csv
10/10/2014 02:21 AM 52,014 522063.csv
10/10/2014 02:54 AM 80,658 5276341.csv
10/10/2014 02:56 AM 96,694 5403381.csv
10/10/2014 01:53 AM 64,195 5448.csv
10/10/2014 02:03 AM 51,326 55332.csv
10/10/2014 01:53 AM 58,120 5537.csv
10/10/2014 01:53 AM 41,195 5794.csv
10/10/2014 01:53 AM 63,153 5864.csv
10/10/2014 01:53 AM 44,502 6026.csv
10/10/2014 03:04 AM 50,907 6117835.csv
10/10/2014 01:53 AM 40,444 6215.csv
10/10/2014 01:53 AM 37,645 6435.csv
10/10/2014 01:54 AM 43,761 6518.csv
10/10/2014 02:23 AM 42,065 654973.csv
10/10/2014 01:51 AM 36,535 675.csv
10/10/2014 02:23 AM 88,419 683408.csv
10/10/2014 03:12 AM 48,641 6945753.csv
10/10/2014 03:12 AM 44,313 6954108.csv
10/10/2014 01:54 AM 37,369 7189.csv
10/10/2014 01:54 AM 39,546 7244.csv
10/10/2014 01:54 AM 42,138 7489.csv
10/10/2014 01:54 AM 57,153 7554.csv
10/10/2014 03:16 AM 54,545 7730623.csv
10/10/2014 02:24 AM 43,948 777000.csv
10/10/2014 01:54 AM 49,534 7856.csv
10/10/2014 02:24 AM 35,862 785984.csv
10/10/2014 01:54 AM 39,167 7903.csv
10/10/2014 03:19 AM 61,980 8019757.csv
10/10/2014 02:24 AM 54,068 816613.csv
10/10/2014 02:24 AM 58,442 825739.csv
10/10/2014 01:54 AM 58,106 8288.csv
10/10/2014 01:54 AM 66,582 8294.csv
10/10/2014 03:23 AM 46,907 8338263.csv
10/10/2014 01:54 AM 46,174 8366.csv
10/10/2014 01:51 AM 44,154 837.csv
10/10/2014 03:24 AM 89,943 8384326.csv
10/10/2014 03:24 AM 55,395 8461488.csv
10/10/2014 01:54 AM 54,400 8488.csv
10/10/2014 01:54 AM 42,212 8520.csv
10/10/2014 03:26 AM 62,765 8662515.csv
10/10/2014 01:51 AM 51,979 883.csv
10/10/2014 01:54 AM 41,038 9036.csv
10/10/2014 01:51 AM 49,197 913.csv
10/10/2014 03:31 AM 53,699 9279041.csv
10/10/2014 01:51 AM 46,190 995.csv
10/10/2014 01:54 AM 43,594 9978.csv
12/28/2014 12:16 AM 0 filelist.txt
12/28/2014 12:11 AM 8,193 Milad.cpp
12/28/2014 12:12 AM 184,320 Milad.exe
12/28/2014 12:12 AM 391,075 Milad.obj
213 File(s) 11,395,151 bytes
2 Dir(s) 14,019,293,184 bytes free
VulpesPosted Dec 27, 2014, 2:35 PM
The 'move' command moves all the files (*.*) from the sub-folder to the folder itself.
The 'rd' command removes the sub-folder.
The 'dir' command lists the files in the current folder so you can check that the other commands have done what you expected them to do.
Joe WilsonPosted Dec 27, 2014, 1:45 PM
and what do you mean by explaining the text below:
To deal with that, whilst you're in the d:\DS_Project folder, type this:
move files.csv\*.*
rd files.csv
If you run the 'dir' command you should now see files.csv and all the individual .csv files listed in d:\DS_Project.
Please describe and explain more.
VulpesPosted Dec 27, 2014, 1:15 PM
The files to be processed are in a sub-folder of the d:\DS_Project called files.csv.
They are not in the folder itself which is what the program is assuming.
To deal with that, whilst you're in the d:\DS_Project folder, type this:
move files.csv\*.*
rd files.csv
If you run the 'dir' command you should now see files.csv and all the individual .csv files listed in d:\DS_Project.
If you do, then try to run the executable again with:
Milad.exe
Joe WilsonPosted Dec 27, 2014, 7:04 AM
Volume in drive D has no label.
Volume Serial Number is 68AC-C111
Directory of D:\DS_Project
12/27/2014 03:28 PM
12/27/2014 03:28 PM
12/24/2014 06:52 PM
12/27/2014 03:28 PM 0 Flist.txt
12/24/2014 07:03 PM 8,214 Milad.cpp
12/24/2014 06:59 PM 201,216 Milad.exe
12/24/2014 06:59 PM 479,726 Milad.obj
4 File(s) 689,156 bytes
3 Dir(s) 194,734,579,712 bytes free
So, Could you please explain what the problem is.
VulpesPosted Dec 27, 2014, 6:49 AM
Joe WilsonPosted Dec 27, 2014, 1:23 AM
Volume in drive D has no label.
Volume Serial Number is 68AC-C111
Directory of d:\program files (x86)\microsoft visual studio 11.0\vc\bin
12/27/2014 09:50 AM
12/27/2014 09:50 AM
01/04/2014 12:23 AM
10/11/2014 09:28 PM
01/03/2014 11:54 PM
07/26/2012 07:08 PM 173,000 atlprov.dll
11/06/2012 01:20 AM 87,496 bscmake.exe
11/06/2012 01:20 AM 747,464 c1.dll
11/06/2012 01:20 AM 990,144 c1ast.dll
11/06/2012 01:20 AM 2,593,232 c1xx.dll
11/06/2012 01:20 AM 2,767,840 c1xxast.dll
11/06/2012 01:20 AM 3,593,672 c2.dll
11/06/2012 01:20 AM 160,696 cl.exe
11/05/2012 07:55 PM 409 cl.exe.config
12/22/2014 02:36 PM
11/06/2012 01:20 AM 42,968 cvtres.exe
11/06/2012 01:20 AM 1,350,080 dpcmi.dll
11/06/2012 01:20 AM 25,056 dumpbin.exe
11/06/2012 01:20 AM 25,032 editbin.exe
01/04/2014 12:23 AM
12/27/2014 09:44 AM 2,361 filelist.txt
12/27/2014 09:50 AM 0 flist.txt
11/06/2012 01:20 AM 25,016 lib.exe
11/06/2012 01:20 AM 759,232 link.exe
11/05/2012 07:55 PM 409 link.exe.config
06/23/2012 04:24 PM 2,523,240 localespc.dll
12/22/2014 02:37 PM
11/06/2012 01:20 AM 434,616 ml.exe
11/06/2012 01:20 AM 1,836,512 mspft110.dll
11/06/2012 01:20 AM 102,848 nmake.exe
07/26/2012 07:08 PM 58,816 pgocvt.exe
07/26/2012 07:08 PM 65,488 pgodb110.dll
07/26/2012 07:08 PM 85,952 pgomgr.exe
07/26/2012 07:08 PM 46,032 pgort110.dll
07/26/2012 07:08 PM 59,848 pgosweep.exe
11/06/2012 01:20 AM 27,104 undname.exe
11/06/2012 01:20 AM 81,880 vcmeta.dll
11/06/2012 01:20 AM 17,856 vcmui.dll
10/01/2012 09:09 AM 4,452 vcvars32.bat
10/11/2014 09:17 PM
10/11/2014 09:17 PM
11/06/2012 05:43 AM 47,584 xdcmake.exe
10/01/2012 08:21 AM 370 xdcmake.exe.config
33 File(s) 18,736,705 bytes
10 Dir(s) 194,734,862,336 bytes free
So, please analyze this and help me to solve the problem and errors.
VulpesPosted Dec 26, 2014, 5:37 PM
The 'dir' command just produces a listing of files. It doesn't copy or interfere with those files in any way.
Normally, 'dir' lists the files to the console. However, we're redirecting its output to a file, filelist.txt, so that you can easily copy the contents and paste them into your next post.
Joe WilsonPosted Dec 25, 2014, 1:19 AM
VulpesPosted Dec 24, 2014, 2:55 PM
I'm just trying to figure out why it's working on my machine but not on yours and the logical place to start is to check that all the files are there.
Joe WilsonPosted Dec 24, 2014, 2:47 PM
VulpesPosted Dec 24, 2014, 2:03 PM
dir > filelist.txt
To see what's in the directory you then need to open filelist.txt:
notepad filelist.txt
and copy everything in it so you can paste it to a new forum post. I can then check what's in the d:\cpp_projects folder to see if we're missing something.
Joe WilsonPosted Dec 24, 2014, 1:56 PM
Please explain more about these.
VulpesPosted Dec 24, 2014, 11:17 AM
I just want to check that all the files which should be in that folder are in fact in there.
So whilst you're at the command prompt, type this:
dir > filelist.txt
and then
notepad filelist.txt
Now press Ctrl A to select the contents of this file and Ctrl C to copy it to the clip-board.
Finally, paste the contents into your next forum post by pressing Ctrl V.
Joe WilsonPosted Dec 24, 2014, 10:56 AM
VulpesPosted Dec 24, 2014, 7:27 AM
The command prompt should then change to:
d:\cpp_projects >
I've had a look at improving execution speed and I started by changing the linked lists we were using previously to vectors. As we're only adding stuff at the end of the list - not inserting it in the middle - I thought this might improve matters a bit but, in the event, it made little difference :(
I then looked at compiler optimizations and found that if we optimized for speed (/O2 compiler switch), it improved performance about 10 fold which meant that on my Pentium i3 laptop (not the fastest machine in the world) it ran in about 3 seconds.
It's still going to take a long time to deal with 200+ files but it's probably as good as we can get it.
Here's the latest version of the program:
cl /EHsc /O2 joe.cpp
Joe WilsonPosted Dec 23, 2014, 8:58 AM
I must type d: into command propmt and by the way, I hope you will have quicken up the program by 2015/17/01.
VulpesPosted Dec 23, 2014, 8:32 AM
Joe WilsonPosted Dec 23, 2014, 7:41 AM
Is any other solution for my problem? I remember you have told that there is other way which is more efficient than the code you had sent before. Please explain your solution.
VulpesPosted Dec 22, 2014, 3:56 PM
The only difference is that it's not the joe.cpp file which runs.
The C++ compiler, cl.exe, generates a binary file, joe.exe, from the .cpp file by converting it to native code and linking in any libraries which we're calling. It's joe.exe which actually runs.
Joe WilsonPosted Dec 22, 2014, 1:49 PM
in the command prompt and after that run the notepad which I have saved the code in it,
Please check if there is any misunderstood in my description.
VulpesPosted Dec 22, 2014, 10:14 AM
Joe WilsonPosted Dec 22, 2014, 7:28 AM
md c:\cpp_projects
cd c:\cpp_projects
but I don't really understand about this description :
The latest version of the cpp file (which I called joe.cpp for now) also needs to be copied to this directory. Alternatively, you can create it from scratch by typing:
notepad.exe
pasting the following code into the window and saving it as joe.cpp within the cpp_projects folder:
please explain more about which directory I must copy the cpp file and do you mean cpp file is the project file which prefix is cpp , and about exe file.
Do you mean that I must copy and paste the code to the visual studio c++ window which name is joe ,then copy the created program to the folder I have created before.
By the way, please look at the error that compiler gives me.
VulpesPosted Dec 22, 2014, 6:33 AM
There's nothing complicated about this. To create it, just do:
md c:\cpp_projects
and to make it your current working directory, do:
cd c:\cpp_projects
Then copy all the files to this directory. You can either do this from within the command prompt (using the copy command) or from outside it using the normal copy and paste operations.
files.csv should now contain a list of the 8 files you uploaded:
The latest version of the cpp file (which I called joe.cpp for now) also needs to be copied to this directory. Alternatively, you can create it from scratch by typing:
notepad.exe
pasting the following code into the window and saving it as joe.cpp within the cpp_projects folder:
I'm not saying that it won't work with 220 files - I'm just saying that, judging by the time it took to process 8 files, you'll probably be waiting 'all day' for some output!
When I have more time, I'll try and 'quicken up' the program but the important thing just now is for you to get the code to work for a small number of files.
Joe WilsonPosted Dec 22, 2014, 5:32 AM
VulpesPosted Dec 21, 2014, 4:22 PM
However, performance wasn't good which isn't entirely surprising as there's a massive amount of processing going on even for all combinations of only 8 files.
I'll have to see if I can find a way to quicken it up but, of course, none of this matters if you can't read the files in the first place!
Joe WilsonPosted Dec 19, 2014, 1:14 AM
VulpesPosted Dec 18, 2014, 4:39 PM
So just zip (or rar) the solution folder and upload it with your next post.
Joe WilsonPosted Dec 18, 2014, 12:42 PM
VulpesPosted Dec 18, 2014, 6:36 AM
Regarding the setting of the working directory, did you try $(TargetDir) rather than $(ProjectDir)\Debug?
Joe WilsonPosted Dec 17, 2014, 1:35 PM
Furthermore, the my files name are numbers like 835 or 1152 or ... so when compiler want to access to them the location of them are not clear, and I have changed the working directory to projectdir\debug can't access to files in debug folder, this problem make me nervous, please help me
VulpesPosted Dec 17, 2014, 7:01 AM
However, if you've exported the worksheet contents to a .csv file, then those will be text files. A possible problem is that the fields may be enclosed in quotes which would need to be removed before they could be parsed.
If you're having difficulty trying to run this program from VS, then I could try and show you how to run it from the command line instead. Do you want to do that?
Joe WilsonPosted Dec 17, 2014, 6:21 AM
by the way, the files are excel files is there any difference between files.csv and excel files?
VulpesPosted Dec 16, 2014, 12:47 PM
Joe WilsonPosted Dec 16, 2014, 10:22 AM
Please guide me?
VulpesPosted Dec 16, 2014, 6:00 AM
So, if you've copied all of them to the executable folder then, yes, change the working directory to: $(ProjectDir)\Debug
Joe WilsonPosted Dec 16, 2014, 1:58 AM
VulpesPosted Dec 15, 2014, 5:09 PM
If that's the case then it's an easy alteration to make:
VulpesPosted Dec 15, 2014, 4:16 PM
H:\Program Files\Graph1.1\debug\
that's not the same as the 'project folder' which, as mentioned previously, I'd expect to be:
H:\Program Files\Graph1.1\Graph1.1\
However, if you don't want to move the files again, you can change the working directory instead to point to the .exe folder.
If you go to Project menu -> Properties -> Configaration Properties ->Debugging -> Working Directory and change it from:
then hopefully it will work.
If it still doesn't work, try changing the working directory instead to:
I'll get back to you on the other point later as that will mean rewriting the program yet again.
Joe WilsonPosted Dec 15, 2014, 2:50 PM
I think it will look in the project directory by default whose path - judging by the path in the error message - will be:
H:\Program Files\Graph1.1\Graph1.1\
I copied the files to the program folder but I don't understand why that error appeared ,please help me to solve the problem.
By the way, the csv files that I have given , have string and their number which is separated by ( , ) so how can I rewrite the program?
VulpesPosted Dec 15, 2014, 2:30 PM
The path to the project folder should be the one I gave in my previous post.
So, if they're not in there already, I'd copy them into that folder and see if it will work then.
Joe WilsonPosted Dec 15, 2014, 2:00 PM
By the way, the number of each string in the each csv file is separated by (,) so I think I should use split to distinguish the string and the number of each string to use it while calculating the weight of the edge, please help me to do that.
VulpesPosted Dec 15, 2014, 10:56 AM
Which folder have you copied them to?
I think it will look in the project directory by default whose path - judging by the path in the error message - will be:
H:\Program Files\Graph1.1\Graph1.1\
Joe WilsonPosted Dec 15, 2014, 6:15 AM
note: graph1.1 is the program name .
Debug assertion failed!
program: H:\Program Files\Graph1.1\debug\graph1.1.exe
File c:\program files\ microsoft visual studio 10.0\vc\include\vector
Line: 932
Expression: vector subscript out of range
please help me to solve this problem.
VulpesPosted Dec 11, 2014, 1:47 PM
Joe WilsonPosted Dec 11, 2014, 12:56 PM
VulpesPosted Dec 11, 2014, 9:20 AM
After reading this file, you're then in a position to generate all possible pairings of these files and to process them.
Of course, to do this you still need to read each file individually.
I did think of reading the info in all the files first before generating and looping through the pairings. However, the trouble with this approach is that it will require a lot of memory to store the info.
At present, we're just reading the info for each pairing into two structs and then overwriting the structs with the info for the next pairing so hardly any memory is used for that purpose.
You could also save memory by replacing each file name with a number (say the number of the line in files.csv) when you populate the graph. However, I haven't attempted anything like this since it might not be very convenient when processing the nodes in the graph.
Joe WilsonPosted Dec 11, 2014, 9:02 AM
VulpesPosted Dec 10, 2014, 6:38 AM
file1.csv
file2.csv
file3.csv
(and so on)
After reading in the contents of this file, the program now considers each combination of the files, taken 2 at a time, and processes them in the same way as previous versions did.
However, if you have more than 1000 files I wouldn't expect this to work quickly as there will be upwards of a million nodes in the graph.
Although I've left it in for testing purposes, you may want to remove any code which prints values to the console:
For various reasons I nearly always use the command line VC++ compiler when writing C/C++ code for this forum so, if any support files are needed, I either create them in the directory I use for such programs or copy them to that directory so that I can use 'unqualified' file names.
If you're using the Visual Studio IDE, then you can still do the same thing. The path to the executable will typically be on these lines:
C:\Users\someusername\Documents\Visual Studio 2010\Projects\someprogram\someprogram\debug
However, you'll find that there are already quite a lot of files in this directory and so I don't think it will be practicable to add 1000 plus text files to it. It might be better to either leave them where they are and build the full path in the program when you open them or to put them in a sub-folder of the project or executable folder and then use a 'relative' path.
What you don't want to do here is to save the full file path to the graph as this will waste memory needlessly.
Joe WilsonPosted Dec 9, 2014, 9:22 AM
VulpesPosted Dec 8, 2014, 4:35 PM
In that case, you could have a list of files to be compared and the program could figure out all possible combinations of those files, taken two at a time, and run the code on each combination.
Yes, it's a good idea to copy all files you use to the project folder. In fact, in my application, I created them in the same folder as the executable itself so I could use unqualified paths.
Joe WilsonPosted Dec 8, 2014, 2:20 PM
In addition, for accessing the file if I want to avoid using the location is it possible to copy my files.csv to the project location?
VulpesPosted Dec 8, 2014, 10:28 AM
Joe WilsonPosted Dec 8, 2014, 9:55 AM
VulpesPosted Dec 8, 2014, 6:11 AM
http://www.cplusplus.com/reference/utility/pair/
Joe WilsonPosted Dec 8, 2014, 4:06 AM
VulpesPosted Dec 7, 2014, 6:06 PM
// note that de-referencing iterator returns the key which is a pair object
Joe WilsonPosted Dec 7, 2014, 6:48 AM
VulpesPosted Dec 5, 2014, 12:18 PM
http://www.technical-recipes.com/2012/modelling-networks-as-graphs/
You'll see that rather than using an adjacency matrix or list which is the usual basis for implementing a graph, this code uses a map instead. This is how I'd probably have done it myself as it neatly ties together each node pair and the weight of the edge between them. Moreover, you can specify whether the edges are to be directed or undirected - I've assumed you'll want the latter here.
Better still, this code isn't from a copyright book and the author has kindly donated it to the public domain so we can use it as we wish.
The only change I've made to the code is to use a pair of strings rather than a pair of ints so the whole thing now is as follows:
/* Graph.h */
/* Graph.cpp */
/* joe_wilson_graph.cpp or whatever you've called it */
Joe WilsonPosted Dec 5, 2014, 3:27 AM
VulpesPosted Dec 3, 2014, 6:34 PM
It's assumed that the pairs of file names are contained in a file called files.csv, with each pair on a separate line separated by a space i.e:
file1.csv file2.csv
file3.csv file4.csv
(and so on)
You'll see that I've added the results (i.e. the two file names and the value of 'f') to a linked list of structs which I've called NODE for want of a better name.
You can now add this data to your graph. As there's no graph class in the C++ standard library, I haven't attempted to do this myself but, if you don't have one already, there should be plenty of implementations available on the Internet and there might be one in the BOOST library if you have that.
Joe WilsonPosted Dec 3, 2014, 2:59 PM
VulpesPosted Dec 2, 2014, 3:05 PM
/* file1.csv */
/* file2.csv */
As you said you wanted linked lists, I've used std::list rather than std::vector since the latter is not implemented as a linked list:
The output is the same as before, namely:
Joe WilsonPosted Dec 2, 2014, 11:59 AM
VulpesPosted Dec 1, 2014, 5:18 PM
Joe WilsonPosted Dec 1, 2014, 2:08 PM
I want to design a graph which vectors are the files that I have given before, and to allocate a value to edge of vectors so I use F( f1,f2 ) function's result that I explained before which had been calculated by the same tags of two file . So,first I must access to text files tags next use link list to find the same tags of files .Then use F( f1,f2 ) function.
By the way, The files are text files instead of HTML files , and as I said before the tags are strings.
VulpesPosted Dec 1, 2014, 1:21 PM