In windows, there is great command for data comparing which is File compare or
FC.
The FC (File Compare) command in Windows can be used to
compare two files (txt or csv) and display the differences between them.
However, it cannot directly compare CSV (comma-separated values) files as it
treats them as binary files.
FC [/A] [/C] [/L] [/LBn] [/N] [/OFF[LINE]] [/T] [/U] [/W] [/nnnn]
[drive1:][path1]filename1 [drive2:][path2]filename2
FC /B [drive1:][path1]filename1 [drive2:][path2]filename2
/A------------Displays only first and last lines for each
set of dif
/B------------ Performs
a binary comparison.
/C------------ Disregards
the case of letters.
/L------------ Compares
files as ASCII text.
/LBn------------ Sets
the maximum consecutive mismatches to the specifinumber of lines.
/N------------ Displays
the line numbers on an ASCII comparison.
/OFF[LINE]------------ Do
not skip files with offline attribute set.
/T------------ Does
not expand tabs to spaces.
/U------------ Compare
files as UNICODE text files.
/W------------ Compresses
white space (tabs and spaces) for compariso
/nnnn------------ Specifies
the number of consecutive lines that must ma after a mismatch.
[drive1:][path1]filename1------------ Specifies the first file or set of files to
compare.
[drive2:][path2]filename2------------ Specifies the second file or set of files to
compare.
Issue 1: Comparing Two Huge Data Files and data Order same
2. In the address bar, type "CMD" and press
Enter to open the command prompt.
3. The command prompt will open, displaying the current
directory path.
4. In the command prompt, use the following command:
"FC file1.csv file2.csv"
5. The command prompt will display a message stating that
no differences were encountered, indicating that both files have the same data
in the same order.
If the two files are located in different folders, you
can still use the above steps with a slight modification. Instead of providing
just the file names, you need to enter the complete file paths in the FC
command.
For example: "FC c:/home/sreenu/file1.csv
d:/data/file2.csv"
If you want to save the result of the comparison in
either a CSV or TXT file, you can add "> result.csv" to the end of
the command. This will redirect the output to a file named
"result.csv" in the current working directory.
2. Sort the data using the
sort command:
sort filename > newfilename
3. Once the data is sorted and
saved with a new name, use the FC command to compare the files:
fc newfile1 newfilename2
1.Go to file path
2.Sort the data using sort command Sort filename>
newfilename
3.Then use fc command as follows Fc newfile1 newfilename2
4. After running the fc command, you will see the
differences between the two files displayed in the command prompt.
5. If there are no differences, the command prompt will
display "FC: no differences encountered."
6. If there are differences, the command prompt will
display the line numbers where the differences occur.
7. You can then analyze the differences and determine if
the order of the data in the files is not the same.
8. If the order is indeed different, you can take
appropriate actions to handle the differences, such as sorting the data in both
files before comparing them again.
9. You can repeat the process until the data order is the
same in both files or take further actions based on your requirements.
·
The order of the data in both files should also be
the same.
·
If the data is not sorted, it is necessary to sort
the data in the file and then compare it using the FC command.
0 Comments
Thanks for your message.