Batch/mass-convert EDAT3 files to CSV

Comments

6 comments

  • Avatar
    David McFarlane

    Well that Python script certainly is an interesting find.  I suppose one might adapt it to work with edat3 files.  As far as I can tell, little or nothing has changed in the edat file format from 2 to 3, other than changing the file extension from edat2 to edat3.

    Other than developing your own software tool to do the mass conversion, you might have to convert each file individually using E-DataAid 3.  Might turn out to be the same amount of labor either way, but it might help the community if you developed the batch conversion tool and released it.

    0
    Comment actions Permalink
  • Avatar
    Dennis Thompson

    I wrote a simple Windows PowerShell script to automate the conversion of edat to csv.

    # Dennis Thompson UC Davis Imaging Research Center
    # Escape Path Delimiters
    # Remember to add Delimiter to end of path
    # ControlFile is used by E-DataAid to control the command line conversion
    # Location where ControlFile will be written
    $ControlFile='C:\\temp\\Nback_Megan\\ControlFile.txt'
    # Where to write output files
    $OutPutLoc='C:\\temp\\Nback_Megan\\converted\\'
    # Where RAW edat files are located
    $EdatLoc='C:\\temp\\Nback_Megan\\'
    # Filter used to select files
    $EdatFilter='*.edat2'
    # E-DataAid Location
    #$DataAid='C:\Program Files (x86)\PST\E-Prime 2.0\Program\E-DataAid.exe' 
    $DataAid='C:\Program Files (x86)\PST\E-Prime 2.0\Program\'
    # DataAid Options
    $Options='/e /f'


    $files=get-childitem $EdatLoc -include $EdatFilter -name

    ForEach($infile in $files){
        # get the base name of the edat file
        $foo = $infile.split(".")
        $newname = $foo[0]
        # output name of file being converted
        echo $infile
        $strings=@()
        $strings+="Inheritance=NULL"
        $strings+="InFile=$EdatLoc$infile"
        $strings+="OutFile=$OutPutLoc$newname.csv"
        $strings+="ColFlags=1"
        $strings+="ColNames=1"
        $strings+="Comments=1"
        $strings+="BegCommentLine="
        $strings+="EndCommentLine="
        $strings+="DataSeparator=,"
        $strings+="VarSeparator=,"
        $strings+="BegDataLine="
        $strings+="EndDataLine="
        $strings+="MissingData=NaN"
        $strings+="Unicode=0"
        $strings | Set-Content -Path $ControlFile
        #Get-Content -Path $ControlFile
        start-process "E-DataAid.exe" -ArgumentList "$Options $ControlFile" -Wait -WorkingDirectory "$DataAid"
        $filedata = Get-Content "$OutPutLoc$newname.csv"
        #$filedata[4..($filedata.length - 1)] | sc "$OutPutLoc$newname.txt" -Encoding ASCII
        $filedata[4..($filedata.length - 1)] | Set-Content -Path "$OutPutLoc$newname.csv"

    }

     

    1
    Comment actions Permalink
  • Avatar
    Dennis Thompson

    Oh this is the E-Prime 2 version . But I have used it with E-Prime 3 files. 

    0
    Comment actions Permalink
  • Avatar
    David McFarlane

    Very nice -- I never thought about running E-DataAid as a command-prompt program.  Now I see that this is documented at https://support.pstnet.com/hc/en-us/articles/360020316014-INFO-Using-E-DataAid-exe-with-Command-Line-Interpreters-25323-

    0
    Comment actions Permalink
  • Avatar
    Weimin Zheng

    Hi, Dennis, I tried to run your pwsh scripts, but encounter the following errors on line 46"

    Line |
      46 |  … $filedata = Get-Content "D:\My Experiments\3.0\MWTC Cognitive Tasks\C …
         |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         | Cannot find path 'D:\My Experiments\3.0\MWTC Cognitive Tasks\Converted\Sub1 - Cognitive Tasks-9-4.csv' because it does not exist.
    InvalidOperation:
    Line |
      48 |      $filedata[4..($filedata.length - 1)] | Set-Content -Path "$OutPut …
         |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         | Cannot index into a null array.

    Any suggestions to fix the error? Greatly appreciated!

    0
    Comment actions Permalink
  • Avatar
    David McFarlane

    PMJI ...  Offhand, I would say that the file  'D:\My Experiments\3.0\MWTC Cognitive Tasks\Converted\Sub1 - Cognitive Tasks-9-4.csv' failed to be created -- have you looked in the folder to see whether or not the file actually exists?  I would also try manually entering a command equivalent to line 45 and see what happens, especially to see whether it creates the specified file.  Etc.

    And now that I look back at the request that started this thread -- Tim Rachul seems to say that he wants to end up with a single .csv file that contains all the data (as opposed to a single .csv file for each run).  For that, I would simply use E-Merge to pull all the data into a single E-DataAid file, and then export that .edat3 file to .csv.  Don't know why I did not think of that before.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk