Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2010
    Posts
    2

    Post Unanswered: newbie requires help

    hi everyone
    i'm new bie in shell scripting.

    i have one problem please solve it:
    i have directory name a40001,a40002...............
    in each directory there is file in sequence like this
    a40001_000000.dat
    a40001_000000.hea
    a40001_000001.dat
    a40001_000001.hea
    a40001_000002.dat
    a40001_000002.hea
    like this there is many more files.
    all .dat file are signal files ,.hea files are header files.
    i have to write script which covert all signal file(.dat) into .txt file or .csv file.
    please respond to this query it's urgent requried.

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    I moved your post into a new thread as it had nothing to do with the thread you posted in.

    What have you tried so far?
    Does the data in each file need altering in any way?
    Have you tried just looping through the directories and files and just renaming each one?
    I appreciate it's urgent but why did your boss assign the task to you?

    Mike

  3. #3
    Join Date
    Jan 2010
    Posts
    2
    hello mike

    thanks for reply.
    sorry i didnt post my script that i have used.my script is like this :

    for i in 'ls -r *.dat'
    do
    rdsamp -r a40001/$i -v >$i.txt
    done;

    but it's not working . please
    give me write solution .
    it's part of my project.

  4. #4
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Few small points:
    • You are using the wrong type of quotes around 'ls -r *.dat'
    • It should be like `ls -r *.dat`
    • This will only work it's way through the files in one directory.
    • To go through all the directories you wanted assuming you're in the base directory use something like `ls -r a4*/*.dat`
    • Why are you passing the existing file names to the command anyway?
    • The -v option should print the headers on standard output so I can't see why they are going to the files called *.hea

    Hopefully that might help. What does your project do? Just out of interest can you tell us what the rdsamp command actually does - I looked it up on the web but it didn't help me much.

    Mike

  5. #5
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1

    For your info

    For those interested see
    physionet.caregroup.harvard.edu/tutorials/physiobank-text.shtml
    Many readers wish to convert binary data from PhysioBank (PhysioNet's data archive) into text form for further processing.
    ...
    Signals such as ECGs, blood pressure waveforms, and other continuously recorded physiologic signals
    ...
    The tool for converting signals to text is rdsamp
    ...
    Code:
    usage: rdsamp -r RECORD [OPTIONS ...]
    where RECORD is the name of the input record, and OPTIONS may include:
     -f TIME     begin at specified time
     -h          print this usage summary
     -H          read multifrequency signals in high resolution mode
     -l INTERVAL truncate output after the specified time interval (hh:mm:ss)
     -p          print times and samples in physical units (default: raw units)
     -s SIGNAL [SIGNAL ...]  print only the specified signal(s)
     -t TIME     stop at specified time
     -v          print column headings
    Last edited by pdreyer; 01-24-10 at 15:57.

  6. #6
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Code:
    #!/bin/sh
    for datfile in `ls */*.dat`
    do
            filename=`echo $datfile|cut -d"." -f1`
            echo input is $datfile output is $filename.txt
            dsramp -r $datfile -v  >$filename.txt
    done

    Based on pdreyer's post, I think that the -v option might cause issues if you need to process the .txt files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •