2 Replies Latest reply on Jun 7, 2007 6:49 PM by steeves

    Reading Text tabs delimited file

    steeves
      Hi,
      I am beginner with Flex and I have searching on forum to found how is possible to read a text file with tabs delimited. I have a file with this structure: (6 columns)

      05.06.2007 19:50 14.9 1.6 4.5 NNW
      05.06.2007 19:55 14.9 1.6 4.5 NW
      05.06.2007 20:00 14.9 2.5 3.7 NW
      05.06.2007 20:05 14.9 2.5 5.5 NW

      I would like put row (text file) into a datagrid. My file is only in text and can't generate in XML format file.

      Anybody can help me ?
        • 1. Re: Reading Text tabs delimited file
          peterent Level 2
          Use HTTPService with resultFormat="text" and your file will be returned to you as a single String.

          The String class has a splice function which can break a String into an Array of Strings. You'll want to first splice the string by the newlines so that you create an Array of Strings, each which make up a row.

          Then use a for-loop over that Array and splice each of those Strings by tab ("\t") and that will give you an Array of each data field. Put that Array into an ArrayCollection which will be the dataProvider for your DataGrid.
          • 2. Re: Reading Text tabs delimited file
            steeves Level 1
            Thanks a lot, now all work great !