loading external files into Lists - examples or potential solutions?

1,824 views
Skip to first unread message

TN

unread,
Mar 3, 2009, 11:41:25 AM3/3/09
to E-Prime
Hi,

I was wondering if anybody had an example or could please point me to
an example of an E-Prime (v2 preferably) program which loads external
files into List.

For my program, we are trying to load different variable values for
various variable. I have found where you tell Eprime to load the
file (in List, go to "Property Page," General Tab) but I cannot seem
to create a file that will load. I tried a .xml and a .csv - both
created by excel. I don't think EprimV2 likes .csv and the .xml file
had errors. I put in the necessary Column headers (weight, nested,
procedure) but it errored on the "Procedure" column. It claimed my
Procedure name was not valid, even though I could see that particular
Trial Procedure directly under the List in the program. I'm not
limited to using .xml or .csv files - that's just where my previous
research lead me.

I am stuck, have looked through some online examples, EPrime's support
forum and have glanced through the manuals but haven't found any
solutions. I would be grateful for any help or examples.

Thanks,
~Tiffany

Greg Osenbach

unread,
Mar 3, 2009, 11:46:28 AM3/3/09
to e-p...@googlegroups.com
Tiffany,

I have been doing this with Tab Delineated Text Files (v.s. .CSV) and it has been working fine for me.  There is an example in the E-Basic help file under the Factor.Load Method.

Factor.Load (method)

 

Syntax

Factor.Load

Description

Loads the attribute and level data into the Factor object.

Comments

Factor.Load applies only when Factor.LoadMethod = ebLoadMethodEmbedded or ebLoadMethodFile

Example

'This example sets the List to be loaded from the file,
'and identifies the text file to be used.

 

List1.LoadMethod = ebLoadMethodFile 

List1.Filename = "MyTextFile.txt" 

List1.Load 

 

'Note: To run this example in E-BasicExample.es, copy the
'script above and paste it into the Setup InLine object.
'Create MyTextFile.txt as a tab-delimited text file containing
'attribute header information in the working directory.

Good Luck,
Greg

Greg Osenbach

unread,
Mar 3, 2009, 11:47:33 AM3/3/09
to e-p...@googlegroups.com
Oh, and as a side note, I also added in a List1.Reset as well.

Best of luck,
Greg

David McFarlane

unread,
Mar 3, 2009, 12:15:52 PM3/3/09
to e-p...@googlegroups.com
BTW, this is easier to figure out in good old EP1. In EP1, using the
default "Embedded" load method on a sample List, you could just
scroll to the bottom of the generated script and see what the
external file had to look like, and you could even copy & paste that
into an external text file as a starting point.

Regards,
-- David McFarlane, Professional Faultfinder

Paul Jackson

unread,
Mar 3, 2009, 3:53:08 PM3/3/09
to e-p...@googlegroups.com
Here is a function that I use to load text files into a List. In this
case the list is called lstTrials and it will only have 2 columns
"TrialStimulus" and "TrialCorrectResponse". I have used variations on
this function for over 5 years with no problems. Note that it can make
the result file look a little messy because it creates a new list
everythime it is run. I found that trying to use the same list can cause
problems. This has only been testing in v1.


Sub LoadBlockData(TempFilename as String)
On Error GoTo E
Dim LevelCount As Long
Dim Count as Long
Dim TrialStimulus As String
Dim TrialCorrectResponse As Long

If FileExists(TempFilename) = False Then
Err.Raise 1001,,"Cannot find file '" & TempFilename &
"'"
End If

LevelCount=0
Set listTrials = New List
'listTrials.Name="listTrial"
listTrials.AddAttrib "TrialStimulus"
listTrials.AddAttrib "TrialCorrectResponse"

Open TempFilename For Input As #1
Do While Not EOF(1)
TrialStimulus="-1"
TrialCorrectResponse=-1
Input #1, TrialCorrectResponse, TrialStimulus
If TrialCorrectResponse=-1 Then
Err.Raise 1001,,"Incorrect Format, or Blank Line
(expected TrialCorrectResponse value '0' or '1')"
End If
If TrialStimulus="-1" Then
Err.Raise 1001,,"Incorrect Format, or Blank Line
(expected TrialStimulus value)"
End If

LevelCount=LevelCount+1
If LevelCount>listTrials.Size Then
listTrials.AddLevel LevelCount
End If
listTrials.SetProc LevelCount, "procTrial"
listTrials.SetAttrib LevelCount, "TrialCorrectResponse",
TrialCorrectResponse
listTrials.SetAttrib LevelCount, "TrialStimulus",
TrialStimulus
'LoadMessage
Loop
Close

Set listTrials.TerminateCondition=Samples(listTrials.Size())
Set listTrials.ResetCondition=Samples(listTrials.Size())
Set listTrials.Order = SequentialOrder

Exit Sub
E:
Close
Err.Raise 1001,,"Loading Block File Data Failed." & ebcr &
Err.Description & ebcr
End Sub

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Paul R. Jackson

Experimental Programmer
School of Psychology
University of Queensland

E: pa...@psy.uq.edu.au
P: 33656950
W: www.psy.uq.edu.au/~paulj
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

TN

unread,
Mar 3, 2009, 5:06:54 PM3/3/09
to E-Prime
I just wanted to say "thank you" to everybody for your help.
Reply all
Reply to author
Forward
0 new messages