Loading External Files Into A List - Proper Set-up

1,617 views
Skip to first unread message

mcgree

unread,
Jan 12, 2010, 7:22:11 PM1/12/10
to E-Prime
Hello,
I am trying to use the Factor.Load method to create a list from a
text file that I specify. (See Post:
http://groups.google.com/group/e-prime/browse_thread/thread/74f87efd6e02fd62/8ed0392bfc37d211?lnk=gst&q=loading+external+files+into+Lists+-+examples+or+potential+solutions%3F#8ed0392bfc37d211.)
However, when I try to run the example from the help file I receive
the following error when I try to compile the program: "child item is
a procedure". I know a little about programming, but not much. Can
anyone help me to fix this problem? Thank you very much in advance!

liwenna

unread,
Jan 13, 2010, 6:15:34 AM1/13/10
to E-Prime
Hello mister mcgree!

Not quite sure about the child-thing but could something be amiss with
the formatting of your .txt file so that a procedure ends up in, for
instance, the nested column instead of the procedure column?

The thread you link too contains a LOT of information and features
while judging from your post I think you are only seeking for a way to
load a .txt file into a list.

Here is a bit more shorthand explanation of the 'basic way to load
a .txt file into a list'.

The .txt file should contain all the column headers of a 'normal
list' (e.g. weight nested procedure) and all your own variables (e.g.
stim) on the first line. Each 'collumn' must be separated by a tab.
The next lines of the .txt files hold the 'content' of each 'cell'
again divided by tabs.

Here is a simple .txt file (but google group doesn't handle tabs too
well... so it is a bit messy).

Weight Nested Procedure stim
1 trialproc 2
1 trialproc 3
1 trialproc 1
1 trialproc 4

Now in e-prime simply add an inline to the procedure that holds your
list and place it right before your list stating something like:

---------------------------

Listname.LoadMethod = ebLoadMethodFile

Listname.Filename = "files/listsubject" & c.GetAttrib("subject") &
".txt"

Listname.Load

-------------------

In the above example listname is the name of your list. Alo: the
"files/" part denotes e-prime to look into a folder called files
that's located within the folder that contains the e-studio file. I do
this to keep things somewhat tidy, if you want to keep your .txt files
in the same folder as your e-studio file is, remove the files/ part.
The listsession" & c.GetAttrib("session") & ".txt" is to show how to
select .txt files based on, for instance, subject number. For subject
1 a file called listsubject1.txt will be opened, for subject 2
listsubject2.txt etc etc. A feature like that is usually needed in
cases where you need lists to be loaded from files.

For the die-hard coders among us you could/should insert a
listname.reset either somewhere AFTER the list has run or at the total
beginning of the above code, before it loads the .txt file into the
list.

Now: you still need a procedure for your list to run. I usually create
the procedure in the list 'the normal way' and leave it sitting there
but you could opt to leave your 'list to be filled' totally empty and
move the procedure to the 'unreferenced e-objects'. The moment
the .txt file is loaded into the list e-prime will start referring to
it.

And that... is pretty much all there is to it.

Unless you need more advanced options of course. In that case: let us
know what you need.

Good luck!


liw

On Jan 13, 1:22 am, mcgree <mcg...@gmail.com> wrote:
> Hello,
> I am trying to use the Factor.Load method to create a list from a

> text file that I specify. (See Post:http://groups.google.com/group/e-prime/browse_thread/thread/74f87efd6....)

liwenna

unread,
Jan 13, 2010, 7:35:03 AM1/13/10
to E-Prime
Confusement I see!

Something is terribly off in the part regarding "files/listsubject" &
c.GetAttrib("subject") & ".txt" and/or the
listsession" & c.GetAttrib("session") & ".txt" . The file that I took
the code from actually uses an attribute called 'group' but as that is
not a standard attribute in e-prime I thought that I would better
replace it by session of subject and apparantly I didn't choose
consequently ;)

mcgree

unread,
Jan 13, 2010, 5:02:09 PM1/13/10
to E-Prime
Thank you for the information. Unfortunately, I think that I have
done what is outlined here, but it doesn't seem to be working.
Obviously, I know that I am doing something wrong, I'm just not quite
sure what. Currently, I am just trying to get a practice program to
work rather than trying to tie together a full program and not be sure
where the errors are coming from. To give a bit more detail, I am
using the E-BasicExample file from the included tutorials. I have
added the following code to the script that is just before the list
named List1:
List1.LoadMethod = ebLoadMethodFile

List1.Filename = "MyTextFile.txt"

List1.Load

Additionally, I have created a .txt file that looks like the
following:
Weight Procedure Nested Stimulus CorrectAnswer
1 TrialProc Y 2
1 TrialProc X 1
1 TrialProc Y 2
1 TrialProc X 1
1 TrialProc Y 2
1 TrialProc X 1

(In the text file the information within each cell is actually located
under the proper title, but the formatting is not working correctly
here.) The only other information that I can think of that may be
helpful is that I have left the list blank with the exception of the
headers which are the same as the ones above.

I also tried two different ways to set up the rest of the code: one
where I left the procedure under the list (normal setup) and one where
I moved it to the unreferenced objects section. The first way
(basically just setting up the program normally) did not compile.
Instead, the "child item is a procedure" error popped up. The second
way (moving the procedure to the unreferenced objects section) allowed
the code to be compiled; however when I actually run the program E-
Prime crashes completely. Does anyone have any further thoughts on
why this may be or what I can do to fix this problem? Thanks!

David McFarlane

unread,
Jan 14, 2010, 5:36:15 PM1/14/10
to e-p...@googlegroups.com
Ah, posting your .txt file was the key. Getting the external file
format right is tricky, and I don't know where PST documents this
(but try the List.Filename, List.LoadMethod, and List.Load topics in
the online E-Basic Help), but I will suggest a way out at the end.

So as a bit of personal exercise, I made a little demo program using
your sample .txt (which I will send you separately). Your main
problem is that your .txt is not properly formatted. In particular,
you have your Procedure and Nested columns mixed up, and you do not
have a tab between the Stimulus and CorrectAnswer headings. With
those changes your file works OK.

You will note that my demo program uses no script. It also has a
fully formed TrialList which then gets replaced by the loaded list (I
set the Weight to 0 as a hint that List entries come from somewhere
else). This is not necessary, but it helps to visualize things.

And here is the real hint: Start by making a small version of your
List in E-Studio, and leave the List Load Method at Embedded. Then
generate the script and look down at the bottom for the generated
embedded List. Copy that into a text editor. Voila! You now have a
properly formatted template that you may edit for your final external
list. Then set your List Load Method to File, etc.

-- David McFarlane, Professional Faultfinder

Patrick

unread,
Apr 19, 2012, 10:26:09 PM4/19/12
to e-p...@googlegroups.com
I'm resurrecting an ancient thread, because a problem emerged when I followed its instructions. Because I had a difficulty with the ideas presented, I'm assuming that sometime in the future someone else may have the issue and I can spare them the grief.
 
(XKCD (as usual) provides some amusing interpretation of the situation http://xkcd.com/979/)
 
In regards to loading a list from text file this information was provided.
 
On Thursday, January 14, 2010 12:15:34 AM UTC+13, liwenna wrote:

....

For the die-hard coders among us you could/should insert a
listname.reset either somewhere AFTER the list has run or at the total
beginning of the above code, before it loads the .txt file into the

list. ...

I had loaded an example scripted in a Eprime List Object, which could be a different size than some of the alternative lists. I followed these instructions (and because I didn't think everything through) placed the List.Reset BEFORE the loading code. This gave me a very unexpected and nonobvious error. At a cursory test everything worked correctly, but it there was a hidden problem. The problem was that the characteristics of the original list was still present and were overwriting infromation about the the new List. Examples to clarify the behavior.
 
Problem Free Example
ListX is a List Object referencing List1 (size = 100 lines)
In an inline Object i replace ListX with List2 (size = 100 lines)
When I run ListX, it has 100 samples. All 100 are from List2. (Everything is fine)
 
Too Short Example
ListX is a List Object referencing List1 (size = 100 lines)
In an inline Object i replace ListX with List3 (size = 80 lines)
When I run ListX, it has 100 samples. 80 from List3 and the last 20 lines from List1.
 
Too Long Example
ListX is a List Object referencing List1 (size = 100 lines)
In an inline Object i replace ListX with List2 (size = 120 lines)
When I run ListX, it has 100 samples. The last 20 lines from List2 are absent from the list.
 
To solve this problem the List.Reset must occur AFTER the List.Load statement.
 
Cheers,
Pt

Patrick

unread,
Apr 19, 2012, 11:15:36 PM4/19/12
to e-p...@googlegroups.com
Apparently I was too hasty in my response.
List.Reset does not entirely fix the issue, the Termination.Condition must also be reset. (As per another post by David)
 
Thus the entire fix would be:
 
List1.LoadMethod = ebLoadMethodFile
List1.Filename = "lists/" & c.GetAttrib("ExpList") & ".txt"  'Load a filename. This just happens to be the one I used.
List1.Load
List1.Reset
Set List1.TerminateCondition = Cycles(1)
Set List1.ResetCondition = Samples(List1.Deletion.Count)
Reply all
Reply to author
Forward
0 new messages