diff <(sort File1.csv) <(sort File2.csv) | grep '^>' | cut -c3-
comm -13 <(sort file1.txt) <(sort file2.txt)
comm -23 <(sort file1.csv) <(sort file2.csv) > file3.csv
grep -v -f file2.csv file1.csv > file3.csv
For whole lines that are present in file1.csv but not in file2.csv you probably want
grep -xvFf file2.csv file1.csv
https://www.tutorialspoint.com/How-to-find-difference-between-2-files-in-Python
FIRST FILE IS MORE RECENT WITH ADDITIONS
python AI
def get_difference(file1_path, file2_path):
"""
Calculates the difference between two files containing numbers.
Args:
file1_path (str): The path to the first file.
file2_path (str): The path to the second file.
Returns:
tuple: A tuple containing two lists:
- Numbers present only in the first file.
- Numbers present only in the second file.
"""
try:
with open(file1_path, 'r') as file1, open(file2_path, 'r') as file2:
numbers1 = set(int(line.strip()) for line in file1)
numbers2 = set(int(line.strip()) for line in file2)
only_in_file1 = list(numbers1 - numbers2)
only_in_file2 = list(numbers2 - numbers1)
return only_in_file1, only_in_file2
except FileNotFoundError:
return "Error: One or both files not found.", "Error: One or both files not found."
except ValueError:
return "Error: Files must contain only numbers.", "Error: Files must contain only numbers."
# Example usage:
file1_path = 'file1.txt'
file2_path = 'file2.txt'
# Create sample files (optional - for testing)
with open(file1_path, 'w') as f:
f.write("1\n2\n3\n")
with open(file2_path, 'w') as f:
f.write("2\n3\n4\n")
diff1, diff2 = get_difference(file1_path, file2_path)
if "Error" not in diff1 and "Error" not in diff2:
print("Numbers only in", file1_path, ":", diff1)
print("Numbers only in", file2_path, ":", diff2)
else:
print(diff1)
https://www.geeksforgeeks.org/compare-two-files-line-by-line-in-python/
Nothing fancy, just a personal log with a built in search function so I can recall what is easily forgotten.
Friday, May 30, 2025
Friday, May 16, 2025
XAMPP on Linux
Commands from Terminal Window:
sudo /opt/lampp/lampp panel
sudo /opt/lampp/lampp start
Chrome: http://localhost/dashboard/
sudo /opt/lampp/lampp stop
sudo /opt/lampp/lampp restart
sudo /opt/lampp/lampp startmysql
sudo /opt/lampp/uninstall
sudo /opt/lampp/lampp panel
sudo /opt/lampp/lampp start
Chrome: http://localhost/dashboard/
sudo /opt/lampp/lampp stop
sudo /opt/lampp/lampp restart
sudo /opt/lampp/lampp startmysql
sudo /opt/lampp/uninstall
Subscribe to:
Posts (Atom)