Tag: Diffing Files

  • Managing Historical files

    Managing Historical files

    If you are working in a team, you may be required to send your progress to the group and also see what others have been doing.

    Team members add unto each others work while modifying each others code.

    You may also finding yourself working on a complex project that has many changes and things you created may got removed and yet you need them later. Other times you need to delete a significant chunk of code and you may need to keep a copy of the whole thing just you change your mind and want to include the code again. If you happen to experience this, then you are likely to have many copies of the same project. Personally when i was working on my project, i had retained many copies of the project because anytime you needed to make changes, you have to create a copy of the project, keep the original and then modify the copy. The old copies of the project files are then one referred to as the historical copies.

    Historical Copies let you see what the project was like before you modified it and lets you back to the old version of the project incase you find that the latest changes were wrong and not needed.

    Historical copies also help you track the progress of your changes with time and helps you understand why changes were made .

    Version control systems let us keep track of the changes in our files by enabling us see who did what, when they did it, who they are and why they did what on a file. The file can be code,images, configurations, video etc.

    One of the best and widely used version control system is Git. Git helps us keep track of our changes and in collaborating with others to avert changes.

    Diffing Files

    it involves comparing two files side by side to see the difference between them. Git will have tools that help the process automatically.

    Suppose we have two versions of the same file called calcultemean.py.

    The first version we call calculatemean1.py and the second we call calculatemean1.py.

    We can use diff command that will highlight only the lines in the two versions that are different.

    marks = [22,66,47,88,32,31,47,67,62,70]
    sum=0
    for i in marks:
    sum +=i
    mean = sum/len(marks)
    print("From manual loop:",mean)

    Here is another version producing the same result with an inbuilt function

    from statistics import mean
    marks = [22,66,47,88,32,31,47,67,62,70]
    mean = mean(marks)
    print("from function:", mean)

    To compare the two files in linux, use the command :

    import re
    diff calculatingmean.py calculatingmean1.py

    Related Topics