openrefinegrel

Extracting week in the year with openrefine


I would like to extract the week in the year from a large dataset. I selected 'Add column based on this column' and used this script ' value.toDate("yyyy/mm/dd").datePart("weeks") '

See attached image

However the result is week in the month but not year.


Solution

  • More about this issue here. Until it is solved, could you switch to Python/Jython and use this script?

    from datetime import datetime
    
    date_time_obj = datetime.strptime(value, '%Y/%m/%d')
    
    return date_time_obj.isocalendar()[1]
    

    enter image description here