If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > newbie requires help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-20-10, 10:11
intel_vikas intel_vikas is offline
Registered User
 
Join Date: Jan 2010
Posts: 2
Post 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.
Reply With Quote
  #2 (permalink)  
Old 01-20-10, 10:40
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,517
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
Reply With Quote
  #3 (permalink)  
Old 01-21-10, 09:43
intel_vikas intel_vikas is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 01-21-10, 10:49
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,517
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
Reply With Quote
  #5 (permalink)  
Old 01-24-10, 15:51
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,258
For your info

For those interested see
physionet.caregroup.harvard.edu/tutorials/physiobank-text.shtml
Quote:
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.
Reply With Quote
  #6 (permalink)  
Old 01-25-10, 10:18
kitaman kitaman is offline
Registered User
 
Join Date: Sep 2009
Location: Ontario
Posts: 526
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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On