1. DELIMITED DATA FILES TO SEQUENCE

I've known about Euphoria for a long time now, but it is untill now
i've tried to learn it. Looks quite powerful, and what I like most
is the SEQUENCEs.

As I make quite a few utilities for workrelated tasks, I was thinking
of going over to Euphoria instead of using O'Basic (which is really
easy, yet quite powerful.) in hope that Euphoria can help me out 
better than the restrictions in O'Basic's arrays. Euphoria is a new
way of thinking, and I haven't quite gotten used to it yet! :D

What I'm looking for is an include file that can read a data file 
(text format - where data is placed in a record/field structure 
separated by a special delim. character, like TAB, ';' etc.)
and build a SEQUENCE from that file.

An example of the content of a file, where [TAB] is the char(9);
HEADING ONE [TAB] HEADING TWO [TAB] HEADING THREE
DATA ONE    [TAB] DATA TWO    [TAB] DATA THREE
DATA ONE    [TAB] DATA TWO    [TAB] DATA THREE

the result would be;
{
{"HEADING ONE", "HEADING TWO", "HEADING THREE"},          -- Record 1
{"DATA ONE", "DATA TWO", "DATA THREE"},                   -- Record 2
{"DATA ONE", "DATA TWO", "DATA THREE"}                    -- Record 3
}

This will be used to view this data for example in Win32Lib's
List View control. (I know how to do that! :D)

I'd probably make it work if really I put my head into it, but right now
im trying to absorb as much as possible about the language, and I'm
spending most of my time getting to know Win32Lib.

What I would like to know is if any of you know if a code snippet
of this sort already exists?

Kenneth 'ZNorQ'

new topic     » topic index » view message » categorize

2. Re: DELIMITED DATA FILES TO SEQUENCE

Yes,  you  can  use  the CSV library, it will read a file separated by
commas  (just  change  it  if you want another delimiter) and return a
sequence as you described below.

http://www.rapideuphoria.com/contrib.htm





Z> posted by: ZNorQ <znorq at holhaug.com>

Z> I've known about Euphoria for a long time now, but it is untill now
Z> i've tried to learn it. Looks quite powerful, and what I like most
Z> is the SEQUENCEs.

Z> As I make quite a few utilities for workrelated tasks, I was thinking
Z> of going over to Euphoria instead of using O'Basic (which is really
Z> easy, yet quite powerful.) in hope that Euphoria can help me out 
Z> better than the restrictions in O'Basic's arrays. Euphoria is a new
Z> way of thinking, and I haven't quite gotten used to it yet! :D

Z> What I'm looking for is an include file that can read a data file 
Z> (text format - where data is placed in a record/field structure 
Z> separated by a special delim. character, like TAB, ';' etc.)
Z> and build a SEQUENCE from that file.

Z> An example of the content of a file, where [TAB] is the char(9);
Z> HEADING ONE [TAB] HEADING TWO [TAB] HEADING THREE
Z> DATA ONE    [TAB] DATA TWO    [TAB] DATA THREE
Z> DATA ONE    [TAB] DATA TWO    [TAB] DATA THREE

Z> the result would be;
Z> {
Z> {"HEADING ONE", "HEADING TWO", "HEADING THREE"},          -- Record 1
Z> {"DATA ONE", "DATA TWO", "DATA THREE"},                   -- Record 2
Z> {"DATA ONE", "DATA TWO", "DATA THREE"}                    -- Record 3
Z> }

Z> This will be used to view this data for example in Win32Lib's
Z> List View control. (I know how to do that! :D)

Z> I'd probably make it work if really I put my head into it, but right now
Z> im trying to absorb as much as possible about the language, and I'm
Z> spending most of my time getting to know Win32Lib.

Z> What I would like to know is if any of you know if a code snippet
Z> of this sort already exists?

Z> Kenneth 'ZNorQ'

new topic     » goto parent     » topic index » view message » categorize

3. Re: DELIMITED DATA FILES TO SEQUENCE

ZNorQ wrote:
> 
> What I'm looking for is an include file that can read a data file 
> (text format - where data is placed in a record/field structure 
> separated by a special delim. character, like TAB, ';' etc.)
> and build a SEQUENCE from that file.

You can use kat's strtok library

http://www.rapideuphoria.com/strtok-v2-1.zip

or Michael Raley's "Parse with Keep" library.

http://www.rapideuphoria.com/kparse.zip

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

4. Re: DELIMITED DATA FILES TO SEQUENCE

ZNorQ wrote:
> 
> I've known about Euphoria for a long time now, but it is untill now
> i've tried to learn it. Looks quite powerful, and what I like most
> is the SEQUENCEs.
> 
> As I make quite a few utilities for workrelated tasks, I was thinking
> of going over to Euphoria instead of using O'Basic (which is really
> easy, yet quite powerful.) in hope that Euphoria can help me out 
> better than the restrictions in O'Basic's arrays. Euphoria is a new
> way of thinking, and I haven't quite gotten used to it yet! :D
> 
> What I'm looking for is an include file that can read a data file 
> (text format - where data is placed in a record/field structure 
> separated by a special delim. character, like TAB, ';' etc.)
> and build a SEQUENCE from that file.
> 
> An example of the content of a file, where [TAB] is the char(9);
> HEADING ONE [TAB] HEADING TWO [TAB] HEADING THREE
> DATA ONE    [TAB] DATA TWO    [TAB] DATA THREE
> DATA ONE    [TAB] DATA TWO    [TAB] DATA THREE
> 
> the result would be;
> {
> {"HEADING ONE", "HEADING TWO", "HEADING THREE"},          -- Record 1
> {"DATA ONE", "DATA TWO", "DATA THREE"},                   -- Record 2
> {"DATA ONE", "DATA TWO", "DATA THREE"}                    -- Record 3
> }
> 
> This will be used to view this data for example in Win32Lib's
> List View control. (I know how to do that! :D)
> 
> I'd probably make it work if really I put my head into it, but right now
> im trying to absorb as much as possible about the language, and I'm
> spending most of my time getting to know Win32Lib.
> 
> What I would like to know is if any of you know if a code snippet
> of this sort already exists?
> 
> Kenneth 'ZNorQ'
> 
global function read_LV(integer id)
    sequence lData,lheads,line,row
        integer cnt,fh
          fh=1
          line={}
          row={}
      -- Output the columns in the right order
      lheads = getColumnHeadings(id)
      for i = 1 to getLVCount(id) do
          for j = 1 to length(lheads) do--the minus one to cut off last col
              lData = getLVItemText(id, i, lheads[j][1])
      line=append(line,lData)
            -- line=line & lData
          end for
           row =append(row,line)
           line={}
      end for
    return row
  end function

don cole
SF

new topic     » goto parent     » topic index » view message » categorize

5. Re: DELIMITED DATA FILES TO SEQUENCE

> ZNorQ wrote:

> > What I'm looking for is an include file that can read a data file 
> > (text format - where data is placed in a record/field structure 
> > separated by a special delim. character, like TAB, ';' etc.)
> > and build a SEQUENCE from that file.
> > 
> > An example of the content of a file, where [TAB] is the char(9);
> > HEADING ONE [TAB] HEADING TWO [TAB] HEADING THREE
> > DATA ONE    [TAB] DATA TWO    [TAB] DATA THREE
> > DATA ONE    [TAB] DATA TWO    [TAB] DATA THREE
> > 
> > the result would be;
> > {
> > {"HEADING ONE", "HEADING TWO", "HEADING THREE"},          -- Record 1
> > {"DATA ONE", "DATA TWO", "DATA THREE"},                   -- Record 2
> > {"DATA ONE", "DATA TWO", "DATA THREE"}                    -- Record 3
> > }

Look at strtok.e in user archives.
It can add, del, sort, find, match, wildmatch, etc. for you, after you read in 
the file, of course. Parse() turns your first example above into the 2nd 
example, and deparse() reverses the process.

Kat

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu