Coder Social home page Coder Social logo

Comments (1)

amhanson9 avatar amhanson9 commented on July 20, 2024

A script that I've since deleted from web-aip worked like this to compare the bag manifest to the WARC MD5 immediately after unzipping.

if os.path.exists("warc_unzip_log.csv"):

# Dataframe with WARC filename and MD5 from the unzipping log.
# Removes ".gz" from the end of the WARC name and removes extra columns so it matches the bag manifest.
log_df = pd.read_csv("warc_unzip_log.csv")
log_df["WARC"] = log_df["WARC"].str.replace(".warc.gz", ".warc", regex=False)
log_df.drop(["AIP", "Zip_MD5", "Fixity_Comparison", "Unzipping_Result"], inplace=True, axis=1)

# Dataframe that combines the WARc rows from the md5 manifests from every bag.
# Removes the path from the WARC filename so it matches what is in the warc unzip log.
bag_df = pd.DataFrame(columns=["Unzip_MD5", "WARC"])
for root, dirs, files in os.walk(f"aips_{date_end}"):
    if "manifest-md5.txt" in files:
        manifest_path = os.path.join(root, "manifest-md5.txt")
        manifest_df = pd.read_csv(manifest_path, names=["Unzip_MD5", "Extra_Space", "WARC"], sep=" ")
        manifest_df.drop(["Extra_Space"], inplace=True, axis=1)
        bag_df = pd.concat([bag_df, manifest_df], ignore_index=True)
bag_df = bag_df[bag_df["WARC"].str.endswith(".warc")]
bag_df["WARC"] = bag_df["WARC"].str.replace("data/objects/", "")

# Compares the two dataframes. If they don't match, saves an error log.
# It will be moved into the AIPs directory in the next step
df = log_df.merge(bag_df, indicator=True, how="outer")
if len(df[df["_merge"] != "both"]) > 0:
    df.to_csv(f"warc_md5_differences.csv", index=False)
else:
    print("All WARC fixity was unchanged")

from general-aip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.