petermeissner / ical

iCalendar parser for R
Other
18 stars 6 forks source link

Interesting that `ical` generates fewer columns: #8

Open petermeissner opened 5 years ago

petermeissner commented 5 years ago

Confirmed, the datetime issue is now fixed. Interesting that ical generates fewer columns:

devtools::install_github("petermeissner/ical")
#> Skipping install of 'ical' from a github remote, the SHA1 (35f7d747) has not changed since last install.
#>   Use `force = TRUE` to force installation
    install.packages("calendar")
#> package 'calendar' successfully unpacked and MD5 sums checked
#> 
#> The downloaded binary packages are in
#>  C:\Users\georl\AppData\Local\Temp\Rtmp6PaiIC\downloaded_packages

    u = "https://github.com/ATFutures/calendar/releases/download/0.0.1/d-mini.ics"
    download.file(url = u, destfile = "d-mini.ics")
    c1 = calendar::ic_read("d-mini.ics")
    ncol(c1)
#> [1] 26
    nrow(c1)
#> [1] 21
    head(c1)
#> # A tibble: 6 x 26
#>   DESCRIPTION UID   SUMMARY `DTSTART;TZID=G~ `DTEND;TZID=GMT~ CLASS
#>   <chr>       <chr> <chr>   <chr>            <chr>            <chr>
#> 1 "Heads-up:~ "040~ Meet-u~ 20181119T110000  20181119T113000  PUBL~
#> 2 "COlin - R~ "040~ R mark~ 20181120T090000  20181120T110000  PUBL~
#> 3 "\\n"       "040~ Send t~ 20181120T090000  20181120T093000  PUBL~
#> 4 "1 week be~ "040~ CDAS c~ 20181120T150000  20181120T160000  PUBL~
#> 5 "Navigatin~ "040~ "ITS R~ 20181121T140000  20181121T150000  PUBL~
#> 6 "The meeti~ "040~ [Envne~ <NA>             <NA>             PUBL~
#> # ... with 20 more variables: PRIORITY <chr>, DTSTAMP <chr>, TRANSP <chr>,
#> #   STATUS <chr>, SEQUENCE <chr>, LOCATION <chr>,
#> #   `X-MICROSOFT-CDO-APPT-SEQUENCE` <chr>,
#> #   `X-MICROSOFT-CDO-BUSYSTATUS` <chr>,
#> #   `X-MICROSOFT-CDO-INTENDEDSTATUS` <chr>,
#> #   `X-MICROSOFT-CDO-ALLDAYEVENT` <chr>,
#> #   `X-MICROSOFT-CDO-IMPORTANCE` <chr>, `X-MICROSOFT-CDO-INSTTYPE` <chr>,
#> #   `X-MICROSOFT-DONOTFORWARDMEETING` <chr>,
#> #   `X-MICROSOFT-DISALLOW-COUNTER` <chr>, `DTSTART;TZID=Greenwich Standard
#> #   Time` <chr>, `DTEND;TZID=Greenwich Standard Time` <chr>,
#> #   `DTSTART;VALUE=DATE` <date>, `DTEND;VALUE=DATE` <date>,
#> #   `DTSTART;TZID=Romance Standard Time` <chr>, `DTEND;TZID=Romance
#> #   Standard Time` <chr>
    c2 = ical::ical_parse_df("d-mini.ics")
    ncol(c2)
#> [1] 12
    nrow(c2)
#> [1] 21
    head(c2)
#>                                                                                                                uid
#> 1 040000008200E00074C5B7101A82E00800000000A422E1FB9167D401000000000000000010000000A5A5A9C201712E4686F3BEF8AA455230
#> 2 040000008200E00074C5B7101A82E00800000000EB39A1D82871D4010000000000000000100000002991E11530BAE14398A3E231D58C870F
#> 3 040000008200E00074C5B7101A82E00800000000A919FB2EF37FD401000000000000000010000000425B16930AE98845BC0A22AC5A61D045
#> 4 040000008200E00074C5B7101A82E00800000000116F453C2B5BD401000000000000000010000000C812F717C6F2E642A23B6EFB717946CD
#> 5 040000008200E00074C5B7101A82E00800000000F03F8842156AD401000000000000000010000000CAA7A28B3690964185045A8D2D80D513
#> 6 040000008200E00074C5B7101A82E0080000000004A85126F07FD4010000000000000000100000006EEE18C0FD2F40449282F0FCD595ACA7
#>                                                                                                                       summary
#> 1                                                                                           Meet-up re global health projects
#> 2                                                                                                R markup training with Robin
#> 3                                                                                           Send tweet re R workshop in Leeds
#> 4                                                                               CDAS cycling inequalities supervisory meeting
#> 5 ITS Research Seminar - Navigating Gender, Using Transportation: Theme and Variations in Urban India by Morgan Campbell, ITS
#> 6                                                         [Envnet] [Capemnet] Leeds Institute for Fluid Dynamics Open Meeting
#>                 start                 end
#> 1 2018-11-19 11:00:00 2018-11-19 11:30:00
#> 2 2018-11-20 09:00:00 2018-11-20 11:00:00
#> 3 2018-11-20 09:00:00 2018-11-20 09:30:00
#> 4 2018-11-20 15:00:00 2018-11-20 16:00:00
#> 5 2018-11-21 14:00:00 2018-11-21 15:00:00
#> 6 2018-11-21 14:00:00 2018-11-21 14:30:00
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            description
#> 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Heads-up: this will be a 3 way meeting now, to include Stephen Turrell from Leeds City Council, on the 9th floor of the Worsley Building.\n
#> 2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       COlin - Robin has agreed to do a training session for me and Roger on R Markup at this date and time if you want to join us.\n
#> 3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   \n
#> 4                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   1 week before send review of lit review and we'll comment on it.\n
#> 5 Navigating Gender, Using Transportation: Theme and Variations in Urban India\n\nPresented by Morgan Campbell<https://environment.leeds.ac.uk/transport/staff/2569/morgan-campbell>, Institute for Transport Studies, University of Leeds.\n\nDate: Wednesday 21st November 2018\nTime: 14.00-15.00\nLocation: rm 1.11 Institute for Transport Studies<http://www.its.leeds.ac.uk/map/>, University of Leeds\nAll welcome. No booking required.\n\nAbstract\nStarting with the awareness of overt patriarchal structures and gender norms that affect when, where, and why women in urban India travel, this presentation focuses on how gender and class positions are moved and removed by available transport. The geographies of Bengaluru and Delhi were chosen for the significant physical and social transformations that reflect realities of globalization, conflicting political ideologies, internal migration, and rapid urbanization. These changes are embedded within slick metro systems, the millions of new car owners, company provided transportation for employees of multinationals, and failing public bus systems. They are transcribed onto the bodies of urban women in which a tension between mobility in a literal sense and immobility with respect to gender norms and socio-economic hierarchies constantly plays out.\n\nBio\nMorgan Campbell is an interdisciplinary researcher with a background in urban planning and gender studies. She has worked on issues related to urbanization, gender, and mobility in India for the past eight years.\n\nWatch recent ITS Research seminars:\nPlanning for sustainable and resilient cities: Improving decision-making through accessibility instruments<https://environment.leeds.ac.uk/transport/events/event/94/planning-for-sustainable-and-resilient-cities-improving-decision-making-through-accessibility-instruments> by Dr Benjamin Buttner, Technical University of Munich.\n"It's time" in Vancouver – Is equity the key to resolving the paradox of mobility pricing?<https://mymedia.leeds.ac.uk/Mediasite/Showcase/default/Presentation/825a83352f334051b6e05b8c47f7a3fc1d> by Dr Abraham Leung, Griffith University, Australia.\nExploring port and mode decisions for grain consolidators in Argentina. A behavioural model<https://mymedia.leeds.ac.uk/Mediasite/Showcase/default/Presentation/bba7e578bbe64299a0e84708275e58701d> by Rodrigo Tapia<https://www.its.leeds.ac.uk/people/r.tapia>, ITS, University of Leeds.\nAn introduction to Pedestrian in the Loop Simulation and the University of Leeds PEDSIM<http://www.its.leeds.ac.uk/fileadmin/documents/seminars/Romano_R_Abstract___Bio_01_03_2018.docx> by Professor Richard Romano, ITS, University of Leeds\n\nTo see more seminars like these, visit the ITS Events webpage: https://environment.leeds.ac.uk/events/6/transport\n\n\n
#> 6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                The meeting will take place on the 21st Nov 2-4pm, Parkinson SR B.08.
#>                                              location  class priority
#> 1                                           Pure cafe PUBLIC        5
#> 2 room 11.01 (small meeting room near LIDA reception) PUBLIC        5
#> 3                                                     PUBLIC        5
#> 4                                           ITS foyer PUBLIC        5
#> 5                                         ITS rm 1.11 PUBLIC        5
#> 6                                   Parkinson SR B.08 PUBLIC        5
#>        transp             dtstamp last_modified    status
#> 1      OPAQUE 2019-02-18 07:56:17          <NA> CONFIRMED
#> 2      OPAQUE 2019-02-18 07:56:17          <NA> CONFIRMED
#> 3      OPAQUE 2019-02-18 07:56:17          <NA> CONFIRMED
#> 4      OPAQUE 2019-02-18 07:56:17          <NA> CONFIRMED
#> 5 TRANSPARENT 2019-02-18 07:56:17          <NA> CONFIRMED
#> 6      OPAQUE 2019-02-18 07:56:17          <NA> CONFIRMED

Created on 2019-09-09 by the reprex package (v0.3.0)

Originally posted by @Robinlovelace in https://github.com/petermeissner/ical/issues/2#issuecomment-529361734

petermeissner commented 5 years ago

Good question!

There seems to be multiple things going on...

# data 
u = "https://github.com/ATFutures/calendar/releases/download/0.0.1/d-mini.ics"
download.file(url = u, destfile = "d-mini.ics")

# calendars 
c1 = calendar::ic_read("d-mini.ics")
c2 = ical::ical_parse_df("d-mini.ics")

# comparison
names(c1)
#>  [1] "DESCRIPTION"                         
#>  [2] "UID"                                 
#>  [3] "SUMMARY"                             
#>  [4] "DTSTART;TZID=GMT Standard Time"      
#>  [5] "DTEND;TZID=GMT Standard Time"        
#>  [6] "CLASS"                               
#>  [7] "PRIORITY"                            
#>  [8] "DTSTAMP"                             
#>  [9] "TRANSP"                              
#> [10] "STATUS"                              
#> [11] "SEQUENCE"                            
#> [12] "LOCATION"                            
#> [13] "X-MICROSOFT-CDO-APPT-SEQUENCE"       
#> [14] "X-MICROSOFT-CDO-BUSYSTATUS"          
#> [15] "X-MICROSOFT-CDO-INTENDEDSTATUS"      
#> [16] "X-MICROSOFT-CDO-ALLDAYEVENT"         
#> [17] "X-MICROSOFT-CDO-IMPORTANCE"          
#> [18] "X-MICROSOFT-CDO-INSTTYPE"            
#> [19] "X-MICROSOFT-DONOTFORWARDMEETING"     
#> [20] "X-MICROSOFT-DISALLOW-COUNTER"        
#> [21] "DTSTART;TZID=Greenwich Standard Time"
#> [22] "DTEND;TZID=Greenwich Standard Time"  
#> [23] "DTSTART;VALUE=DATE"                  
#> [24] "DTEND;VALUE=DATE"                    
#> [25] "DTSTART;TZID=Romance Standard Time"  
#> [26] "DTEND;TZID=Romance Standard Time"
names(c2)
#>  [1] "uid"           "summary"       "start"         "end"          
#>  [5] "description"   "location"      "class"         "priority"     
#>  [9] "transp"        "dtstamp"       "last_modified" "status"

Created on 2019-09-10 by the reprex package (v0.3.0)

petermeissner commented 5 years ago

I browsed through my code ...

ical_parse_df() still does only parse specific columns, namely those that are shown in the example above.

... but ...

There is now a function called ical_parse_jcal() which parses the calendar into so called jcal (Javascript representation of ical data) which basically is a stupid very nested and long and ugly list of lists of lists .... that entails all the data, including meta data.

Now this format has to be made useful --> v0.3.0

Robinlovelace commented 5 years ago

Hi @petermeissner, fantastic work and I understand the logic: best start conservative, exporting only key variables by default. Still I think enabling users to decide which columns they can see will be very useful.