Giter VIP home page Giter VIP logo

Comments (6)

Ianvdl avatar Ianvdl commented on May 29, 2024

I'm seeing the same issue since last week Friday.

So it seems the script expects the Excel file hosted by EPO to have a filename in the format legal_code_descriptions_YYYYMMDD.xlsx but the latest file hosted by EPO changed to
https://webserv.epo.org/projects/d5413/rawdatapublic.nsf/0/C12583380039E7DBC12589290063DE7E/$File/legal_code_descriptions_202307.xlsx
which is in the format YYYY, and then what appears to maybe be a week number?

Anyway, the upstream data source changed stuff, so for now you might be better off patching it out manually until @parkerhancock has the time to fix it.

from patent_client.

Ianvdl avatar Ianvdl commented on May 29, 2024

I added a pull request to fix this issue #95

from patent_client.

caiyishu avatar caiyishu commented on May 29, 2024

Thank you. I tried to fix this issue manually, but it doesn't seem to be working well. Hopefully, @parkerhancock has some better ideas. Thank you again.

from patent_client.

parkerhancock avatar parkerhancock commented on May 29, 2024

Hey team! This is exactly the error - the EPO went and changed their spreadsheet format. I'm going to review the PR this week. I think I also want to see if there's a way I can make similar failures in the future fail a little more gracefully - rather than erroring out the whole library. Thanks!

from patent_client.

Michael-SSC avatar Michael-SSC commented on May 29, 2024

Hi,
thanks for the nice package. I started to play with it yesterday and encounteres the same error @Ianvdl encountered.
Maybe I can contribute a bit (although I am not a very skilled programmer)

it looks as if the proposed fix
"date = datetime.datetime.strptime(date_string, "%Y%W").date()"
returns "date = datetime.date(2023, 1, 1)" - that appears not be the expected week of the year, which should be "07" (or "08" as of today).

For me the following worked:

def has_current_spreadsheet():
con = sqlite3.connect(db_location, timeout=30)
cur = con.cursor()

try:
    #fname = cur.execute("SELECT * FROM meta").fetchone()[0]
    # fetchone only gets the first entry in META which holds not necessarily the file from the latest week
    # at least when I manually edited the meta table to see what happens when file name is an old one
    fname = cur.execute("SELECT * FROM meta").fetchall()
    
    # initiate lists of legal_code_descriptions filenames
    date_strings = []
    
    #date_string = re.search(r"legal_code_descriptions_(\d+)\.xlsx", fname).group(1)
    # step though all rows in meta to collect all dates (years and weeks) in lists
    for name in fname:
        #print (name[0])
        date_string = re.search(r"legal_code_descriptions_(\d+)\.xlsx", name[0]).group(1)
        
        # collect all date_strings
        date_strings.append(date_string)
        
    #print (date_strings)
    
            
    # when tested on 22. Feb 2023 the date/time appended to the EPO excel file has format "YYYYWW"
    # e.g. legal_code_descriptions_202307.xlsx, i.e, week 7 in 2023
    # therefore testing for "%Y%m%d" caused an error that has to be captured
    # note: file was updated by EPO on Wed 23.02.2023 to legal_code_descriptions_202308.xlsx 
    try: 
        # keep this code piece in case EPO changes format back
        date = datetime.datetime.strptime(date_string, "%Y%m%d").date()
        age = datetime.datetime.now().date() - date
        logger.debug(f"Legal Code Database is {age} days old")
        return age.days <= 30
    
    except:
        # initiate date_max that gets the latest date (year and week) from the Excelfile
        date_max = 0
        
        # get latest year and week from dates in META
        date_max = max(date_strings)
        
        # parse date_max for most recent year and week
        year = int(date_max[:4])
        week = int(date_max[4:])

        # get current year and week
        current_year = datetime.datetime.now().isocalendar()[0]
        current_week = datetime.datetime.now().isocalendar()[1]
        # check if year is the same
        if current_year == year :
            age = current_week - week
        else: # when old file is from week 52 or 53 of previous year then it might be outdated
            age = 2
        logger.debug(f"Legal Code Database is {age} weeks old")
        return age < 1

except (sqlite3.OperationalError, TypeError):
    return False

@parkerhancock maybe you can habe a look and see if that helps
Kind regards,
Michael

from patent_client.

parkerhancock avatar parkerhancock commented on May 29, 2024

Fixed in #102

from patent_client.

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.