Skip to content

Instantly share code, notes, and snippets.

@tluyben
Created February 15, 2013 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tluyben/4960736 to your computer and use it in GitHub Desktop.
Save tluyben/4960736 to your computer and use it in GitHub Desktop.
Simple Monkey language CVS parser
Method Parse() ' csv parser
Local _inc:Bool = False
Local afc:Bool = False
Local quote:=New Quote
Local c:String, c1:String = ""
raw = raw + "~n" ' make sure we catch the last one
For Local i := 0 To raw.Length
c = raw[i..i+1]
If i+2 < raw.Length
c1 = raw[i+1..i+2]
Else
c1 = ""
End
If c = "~n" ' done with this one
If quote.quote.Trim().Length > 0 And quote.movie.Trim().Length > 0
quotes.AddLast(quote)
afc = False
quote = New Quote
End
Else If c = "," And Not _inc ' , but not in "
afc = True
Else If c = "~q" And c1 <> "~q"
_inc = Not _inc
Else
If afc
quote.movie = quote.movie + c
Else
quote.quote = quote.quote + c
End
End
End
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment