Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VCalendar Parsing Question

3 views
Skip to first unread message

David Kaye

unread,
Dec 24, 2009, 7:05:36 AM12/24/09
to
This is dumb. I'm trying to think of a way to parse continued lines in a
VCalendar file. The only indication that a line such as a description or a
summary continues on the next line is that the next line begins with a space.

I guess I'm just thick-headed today but I can't think of a good and fast way
to add the following line to the previous line without loading the entire file
as a blob instead of as a line input.

A typical series of lines looks like this:

BEGIN:VEVENT
SUMMARY:Emancipation Proclamation
UID:2008-05-08-...@americanhistorycalendar.com
SEQUENCE:0
RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=1;BYMONTHDAY=1
DTSTART;VALUE=DATE:20080101
DTEND;VALUE=DATE:20080102
CATEGORIES:Civil War Events
LOCATION:Washington, D.C.
DESCRIPTION:On January 1\, 1863 Abraham Lincoln issues the Emancipation Pr
oclamation\, freeing slaves in Confederate-held territory.\n\n\nhttp://Amer
icanHistoryCalendar.com
URL:index.php?option=com_zcalendar&task=view&vmode=e&eid=910
END:VEVENT
BEGIN:VEVENT
SUMMARY:Georgia\, the fourth state
UID:2008-05-02-...@americanhistorycalendar.com
SEQUENCE:0
etc.

Note how the Description field is multi-line. I want to add succeeding lines
to the first but for the life of me I can't can't figure out a good way of
doing it.


Phill W.

unread,
Dec 24, 2009, 8:17:48 AM12/24/09
to
David Kaye wrote:

> This is dumb. I'm trying to think of a way to parse continued lines in a
> VCalendar file. The only indication that a line such as a description or a
> summary continues on the next line is that the next line begins with a space.

> BEGIN:VEVENT


> SUMMARY:Emancipation Proclamation
> UID:2008-05-08-...@americanhistorycalendar.com
> SEQUENCE:0
> RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=1;BYMONTHDAY=1
> DTSTART;VALUE=DATE:20080101
> DTEND;VALUE=DATE:20080102
> CATEGORIES:Civil War Events
> LOCATION:Washington, D.C.
> DESCRIPTION:On January 1\, 1863 Abraham Lincoln issues the Emancipation Pr
> oclamation\, freeing slaves in Confederate-held territory.\n\n\nhttp://Amer
> icanHistoryCalendar.com
> URL:index.php?option=com_zcalendar&task=view&vmode=e&eid=910
> END:VEVENT

With line input, you're going to have to keep track of "where" you are
(which named entry you loaded last) and append any continuation line(s)
onto that.

Line Input sLine, ...

If IsContinuation(sLine) Then
if sCurrentlyLoading = "DESCRIPTION" Then
AppendToDescription( sLine )
Elseif sCurrentlyLoading = "SUMMARY" Then
AppendToSummary( sLine )
. . .
End if
Else
sCurrentlyLoading = Split( sLine, ":")(0)
End if


If you /can/ load the whole thing (even just a VEvent at a time) into a
single string, then ...

stringData = Replace( stringData, vbCrlf & " ", "" )

... will do the job nicely.

HTH,
Phill W.

Jeff Johnson

unread,
Dec 29, 2009, 3:50:13 PM12/29/09
to
"David Kaye" <sfdavi...@yahoo.com> wrote in message
news:hgvlef$vlc$1...@news.eternal-september.org...

> I guess I'm just thick-headed today but I can't think of a good and fast
> way
> to add the following line to the previous line without loading the entire
> file
> as a blob instead of as a line input.

Are you expecting multi-megabyte vCalendar files? If not, bring it all in at
once!


David Kaye

unread,
Dec 29, 2009, 4:32:47 PM12/29/09
to
"Jeff Johnson" <i....@enough.spam> wrote:

>Are you expecting multi-megabyte vCalendar files? If not, bring it all in at
>once!

Yeah, I guess you're right. I'll rework it.

0 new messages