home *** CD-ROM | disk | FTP | other *** search
/ GameStar Special 2004 August / GSSH0804.iso / Action / TumikiFighters / tf0_2.exe / tf / src / abagames / util / csv.d < prev    next >
Text File  |  2004-05-15  |  685b  |  36 lines

  1. /*
  2.  * $Id: csv.d,v 1.2 2004/05/14 14:35:38 kenta Exp $
  3.  *
  4.  * Copyright 2004 Kenta Cho. All rights reserved.
  5.  */
  6. module abagames.util.csv;
  7.  
  8. private import std.stream;
  9. private import std.string;
  10.  
  11. /**
  12.  * CSV format Tokenizer.
  13.  */
  14. public class CSVTokenizer {
  15.  private:
  16.  
  17.   public static char[][] readFile(char[] fileName) {
  18.     char[][] result;
  19.     auto File fd = new File;
  20.     fd.open(fileName);
  21.     for (;;) {
  22.       char[] line = fd.readLine();
  23.       if (!line)
  24.     break;
  25.       char[][] spl = split(line, ",");
  26.       foreach (char[] s; spl) {
  27.     char[] r = strip(s);
  28.     if (r.length > 0)
  29.       result ~= r;
  30.       }
  31.     }
  32.     fd.close();
  33.     return result;
  34.   }
  35. }
  36.