Importing data from Windows/DOS 
Author Message
 Importing data from Windows/DOS

I asked this question before, but was, I think I was misunderstood!  Let's
try again.
I have IBM APL2 under Windows.  I want to take data in a text file under
Windows or DOS and import it as an array under APL2.

Let me be more specific.  Suppose I have a normal Windows or DOS text file
which
looks like a numerical array under Windows or DOS.  Say it has (to be
specific)
10 rows and 50 columns, with 10 numbers in each row given to 4 significant
figures.
A row might look like this:

123.4 567.8 901.2 345.6 789.0 123.4 567.8 901.2 345.6 789.0

I want to get this array as text and assign it to a variable in APL.  After
that
I can manipulate it any way I like. For example,  I could make it into a
numerical
array.

My problem is how to start.  I guess I need to use shared variables?  I know
little about these.  How from APL2 do I access this possibly DOS file in the
A: drive?  Can someone at least point me to where I can find out!  Thanks.

Gerry



Thu, 08 Jul 2004 05:01:00 GMT  
 Importing data from Windows/DOS
Gerry,

I thought Nancy Wheeler and I both answered this question both here and
offline.  Here is the simplest way:

3 11 Quadra 'FILE'
A is FILE 'filename'

Note: Both "Quad" and "is" should be replaced with the obvious APL
characters.

David Liebtag
IBM APL Products and Services



Thu, 08 Jul 2004 06:43:43 GMT  
 Importing data from Windows/DOS

I am attaching a copy of my append to comp.lang.apl of January 8.
Since you gave more detail in your question this time, I would suggest
that the Processor 10 file functions are probably best suited to your needs.
The FILE extrnal function that David suggested will not remove any control
characters, and the Processor 10 functions will.

If you are having trouble finding the APL2 User's Guide, you access it by
clicking on "Help" then "User's Guide" from the APL2 session manager window.

Nancy Wheeler
APL Products and Services
----------------------------------------------------------------------
I am not sure exactly in what context you are using the word "see".
If you mean how to access files from inside the IBM APL2 environment, you have
several different options for doing file I/O, from the simple external function
which reads the entire file as a byte stream, to associated processor 12 which
lets you operate on the file with APL primitives.    Check these sections of the
APL2 User's Guide:
  Associated Processors - Processor 12
  Associated Processors - Processor 10 - File Access Functions
  Supplied External Functions -  FILE
  Supplied Auxiliary Processors - AP 210
Using any of these methods, you can specifiy a complete path for your files,
including drive letter A: (or whatever drive letter is appropriate).



Sat, 10 Jul 2004 03:38:23 GMT  
 Importing data from Windows/DOS

In J you could do something like this:
-----------------------
t=: 1!:1 <'apl2tolur.txt' NB. read the "numbers" in
$t                                NB. check how many chars read in
+/t=CR                       NB. In DOS you have CRLF test for CR
+/t~:CR                      NB. Find everything not CR
t1=:(t~:CR)#t              NB. Remove CR
$t1                              NB. Check how many chars left
t2=: chop each chop t1  NB. Split up into rows and then every row into items
1+".>>t2                       NB. Take the results change into numeric and
add one to each
".>>t2                           NB. Take the results and change into
numeric

-------------------------- then to use it out comes
   require'misc'
   t=: 1!:1 <'apl2tolur.txt' NB. read the "numbers" in
   $t
427
   +/t=CR
7
   +/t~:CR
420
   t1=:(t~:CR)#t
   $t1
420
   t2=: chop each chop t1
   1+".>>t2
124.4 568.8 902.2 346.6 790 124.4 568.8 902.2 346.6 790
125.4 568.8 902.2 346.6 790 124.4 568.8 902.2 346.6 790
126.4 568.8 902.2 346.6 790 124.4 568.8 902.2 346.6 790
127.4 568.8 902.2 346.6 790 124.4 568.8 902.2 346.6 790
128.4 568.8 902.2 346.6 790 124.4 568.8 902.2 346.6 790
129.4 568.8 902.2 346.6 790 124.4 568.8 902.2 346.6 790
130.4 568.8 902.2 346.6 790 124.4 568.8 902.2 346.6 790
   ".>>t2
123.4 567.8 901.2 345.6 789 123.4 567.8 901.2 345.6 789
124.4 567.8 901.2 345.6 789 123.4 567.8 901.2 345.6 789
125.4 567.8 901.2 345.6 789 123.4 567.8 901.2 345.6 789
126.4 567.8 901.2 345.6 789 123.4 567.8 901.2 345.6 789
127.4 567.8 901.2 345.6 789 123.4 567.8 901.2 345.6 789
128.4 567.8 901.2 345.6 789 123.4 567.8 901.2 345.6 789
129.4 567.8 901.2 345.6 789 123.4 567.8 901.2 345.6 789


Quote:
> I asked this question before, but was, I think I was misunderstood!  Let's
> try again.
> I have IBM APL2 under Windows.  I want to take data in a text file under
> Windows or DOS and import it as an array under APL2.

> Let me be more specific.  Suppose I have a normal Windows or DOS text file
> which
> looks like a numerical array under Windows or DOS.  Say it has (to be
> specific)
> 10 rows and 50 columns, with 10 numbers in each row given to 4 significant
> figures.
> A row might look like this:

> 123.4 567.8 901.2 345.6 789.0 123.4 567.8 901.2 345.6 789.0

> I want to get this array as text and assign it to a variable in APL.
After
> that
> I can manipulate it any way I like. For example,  I could make it into a
> numerical
> array.

> My problem is how to start.  I guess I need to use shared variables?  I
know
> little about these.  How from APL2 do I access this possibly DOS file in
the
> A: drive?  Can someone at least point me to where I can find out!  Thanks.

> Gerry




Sun, 11 Jul 2004 08:58:41 GMT  
 Importing data from Windows/DOS
Quote:

> In J you could do something like this:

[snip of a complex solution]

I'm not quite sure why this J solution is being presented here, but
if I understand the problem this is a wildly overcomplex `answer'
that involves some mysterious `misc' and `definitions' which are
idiosyncratic (chop, each)

A simpler J solution would be:

Which `protects' against line feeds and ASCII Eof as well as CRs.
If t1 should be reshaped into a 10 column matrix, then
    t1 =: _10 [ \ t1
would do the job.

However, both this and (I believe) the previous solution run into
serious problems if there is <0 data represented with `-' (minus) signs
rather than `_' (underscore). This problem isn't hard to handle, but
since this isn't a forum in J coding, it doesn't strike me as worth
going after here...



Sun, 11 Jul 2004 03:03:46 GMT  
 Importing data from Windows/DOS


Quote:

> I'm not quite sure why this J solution is being presented here, but
> if I understand the problem this is a wildly overcomplex `answer'

There is always an issue what is complex and what is not.
It all depends on the knowledge of the potential reader.
If a person does not know how to read in a file I think it fair to assume
that the
knowledge base is not very high.

Quote:
> . This problem isn't hard to handle, but
> since this isn't a forum in J coding, it doesn't strike me as worth
> going after here...

This problem was difficult enough to warrant the question to begin with and
then several answers
that did not even come close to pointing at what to do.

Now at least there are two answers that show two ways of doing this with J
and that show both how to accomplish this with J in one line and one where
each step is done in steps.

I see no reason to get into the discussion on whether c.l.a is a forum for
all APL dialects or not.



Mon, 12 Jul 2004 00:25:54 GMT  
 Importing data from Windows/DOS

Quote:

[snip]

> There is always an issue what is complex and what is not.
> It all depends on the knowledge of the potential reader.
> If a person does not know how to read in a file I think it fair to assume
> that the
> knowledge base is not very high.

I find it pointless to argue complexity. However, `incompleteness' does
strike me as relevant, and the solution you presented contains several
undefined terms, contrary to the usual practice of presenting complete and
executable examples that, I believe, generally applies to c.l.a as well as on
JForum and KList. Your code also may well not run in windows as it neglects
Ascii EOF which often terminates ASCII files. Since I can't run the code, though,
I'm not sure about this point.

My point was that I not only found the solution overly complex, but also
`unrunnable' as given.

Quote:
> > . This problem isn't hard to handle, but
> > since this isn't a forum in J coding, it doesn't strike me as worth
> > going after here...

> This problem was difficult enough to warrant the question to begin with and
> then several answers
> that did not even come close to pointing at what to do.

I was speaking of `the problem' of handling negative signs, not `the problem'
in general.

Quote:
> Now at least there are two answers that show two ways of doing this with J
> and that show both how to accomplish this with J in one line and one where
> each step is done in steps.

> I see no reason to get into the discussion on whether c.l.a is a forum for
> all APL dialects or not.

Neither do I.

Which reminds me I might as well present a K `solution':
   t2:.:'0:"apl2tolur.txt"
To test the code I ran both my J and K examples on a 6mb file (200,000 line file
at 8 entries/line) and on my 800mhz machine my J code ran in 5.1 sec and
the K code ran in 6.9 sec.



Sun, 11 Jul 2004 22:59:03 GMT  
 Importing data from Windows/DOS


Quote:

> [snip]
> My point was that I not only found the solution overly complex, but also
> `unrunnable' as given.

That is not the case

It is copied directly from J

chop is provided from the misc library of utils and was provided in the text

require'misc'

 t2=: chop each chop t1



Mon, 12 Jul 2004 07:42:57 GMT  
 Importing data from Windows/DOS

Quote:

> I see no reason to get into the discussion on whether c.l.a
> is a forum for all APL dialects or not.

Nor do I, but I believe the individual who made the request specified that
he wanted to use the data within APL2.  Getting the data into J -- or even
into Dyalog, SAX, or APL2000 -- still leaves it outside of APL2, no?


Mon, 12 Jul 2004 04:12:13 GMT  
 Importing data from Windows/DOS


Quote:

> Nor do I, but I believe the individual who made the request specified that
> he wanted to use the data within APL2.

I have not seen any solution of doing that posted here so he might as well
get J from
http://jsoftware.com/


Tue, 13 Jul 2004 00:14:10 GMT  
 Importing data from Windows/DOS

Quote:

> I have not seen any solution of doing that posted here so he might as well

I've seen at least three.

Ted



Tue, 13 Jul 2004 00:14:21 GMT  
 Importing data from Windows/DOS
Bjorn,

Quote:
> I have not seen any solution of doing that posted here so he might as well

get J from

I don't know why you haven't seen the APL2 solutions.  Nancy Wheeler and I
have made numerous posts replying to Gerry's request for information about
how to do it in APL2.

David Liebtag
IBM APL Products and Services



Tue, 13 Jul 2004 00:15:48 GMT  
 Importing data from Windows/DOS
Referring to users guide and pointing to various
documentation never was a solution to users
problems.

They had the users guide and did not understand it.

Pointing the users again to the users guide make
the users go away from APL. The number of users
who have started trying to use APL and have given up
are a constant proof of that.

This is the main reason why people do not use APL.
They do not understand how to take the first steps and
they give up.

Even those who do manage to get things right by plowing
through the users guide of using these auxilieie... whatever ... give up in
great numbers because it is too cumbersome to work with.

--

/Gosi


Quote:
> Bjorn,

> > I have not seen any solution of doing that posted here so he might as
well
> get J from

> I don't know why you haven't seen the APL2 solutions.  Nancy Wheeler and I
> have made numerous posts replying to Gerry's request for information about
> how to do it in APL2.

> David Liebtag
> IBM APL Products and Services



Tue, 13 Jul 2004 14:17:04 GMT  
 Importing data from Windows/DOS

Quote:
> My point was that I not only found the solution overly
> complex, but also `unrunnable' as given.

Actually since "chop" "each" and friends are defined by the standard J
prologue, I think the solution runs as given. J is a powerful enough
language that it makes sense to give solutions that don't rely on
external definitions. On the other hand, since there's only one
implementation on J, and only one standard distribution of J, then verbs
like "chop" and adverbs like "each" can be considered standard and as
such be used as if they were part of the core language.
After all, "strcpy" as well as "printf" aren't part of the C language,
but nobody would ever consider writing a program including an explicit
definition of them, since they are part of the standard C library.

What do you think?
--

Homepage: currently offline



Sat, 17 Jul 2004 03:32:01 GMT  
 Importing data from Windows/DOS

Quote:
> > I have not seen any solution of doing that posted here so
> he might as
> > well
> get J from

> I don't know why you haven't seen the APL2 solutions.  Nancy Wheeler
> and I have made numerous posts replying to Gerry's request for
> information about how to do it in APL2.

I am not Bjorn, but I've had similar experiences in the past.
Unfortunately, many newsservers treat comp.lang.apl as a second rate
newsgroup. For instance the newsserver of our ISP: I would find random
posts, and never more than a couple a month even if I knew there were
much more (from looking at dejanews) available. Eventually I decided to
subscribe to the maillist which is much more reliable.
--

Homepage: currently offline
<<<For a moment, nothing happened. Then, after a second or so, nothing
   continued to happen. --- The Best Quotes from The Hitchhiker's guide
to
   the Galaxy>>>


Sat, 17 Jul 2004 04:06:37 GMT  
 
 [ 27 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Importing data from DOS

2. importing clarion 2.1 for dos data files

3. Importing data with DOS file driver

4. Import Data With File Import

5. Unix Data files vs DOS data files

6. import Image vs from PIL import Image vs import PIL.Image

7. DOS Box/Full screen from DOS app in Windows

8. Import dos file variable record length

9. Getting a divide by zero while importing an ascii into report writer for DOS - XTRACE included

10. Trying to import/convert V3 for DOS application

11. How to import Cobol DOS Database (with *.idx) in MS Acess

 

 
Powered by phpBB® Forum Software