0

Sample rate calculation is done of .wav data easily using following this code.

sampleRate, data = scipy.io.wavfile.read('ecg.wav')
times = np.arange(len(data))/sampleRate

If I want to calculate same sample rate of my .csv file what should I change in this code? I can read the data using pd.read_csv('ecg.csv') this command. But how can I calculate sample rate?

This is csv data:

enter image description here

Abc
  • 19
  • 6
  • 1
    csv and wav files are entirely different things. csv is like a spreadsheet table. what do you mean sample rate of csv? – DevCl9 Oct 24 '20 at 07:11
  • I am yet to see an audio encoded in spreadsheet format. But even if that's the case, you should provide a sample data to show us how the csv is structured – DevCl9 Oct 24 '20 at 07:13
  • sample rate means frequency of samples used in digital recording. how can I find this sample rate from csv data? – Abc Oct 24 '20 at 07:17
  • I know what sample rate means. The thing is csv isn't used for digital recording to begin with. You might convert wav -> csv for some computing/processing (but even then you should provide how the conversion is conducted or what the csv looks like). It's not like csv is a common sound format – DevCl9 Oct 24 '20 at 07:21
  • 1
    @DevCl9 I have attached this csv file. from this data is it possible to calculate sample rate of data of column 'I'? – Abc Oct 24 '20 at 07:30
  • 1
    @Abc You count the number of rows, look at the last "Elapsed Time" entry, and then calculate the sample rate from that. It's a simple division, rows (=samples) per time. 10,000 rows in 10 seconds = 1000 Hz. It's not hard. – Tomalak Oct 24 '20 at 07:33
  • @Abc If you have the code that does it, post it as an answer below. This way the thread might help someone in the future. – Tomalak Oct 24 '20 at 07:48
  • @Tomalak I don't have any code. I just verified it with my csv data description. Thank you. – Abc Oct 24 '20 at 08:15
  • @Abc But *once you have written the code* that does this, please post it as an answer below. – Tomalak Oct 24 '20 at 08:39

0 Answers0