Converting excel files to python to frequency
Question: Essentially I've got an excel files with voltage in the first column, and time
in the second. I want to find the period of the voltages, as it returns a
graph of voltage in y axis and time in x axis with a periodicity, looking
similar to a sine function.

To find the frequency I have uploaded my excel file to python as I think this
will make it easier- there may be something I've missed that will simplify
this.

So far in python I have:

    
    
    import xlrd
    import numpy as N
    import numpy.fft as F
    import matplotlib.pyplot as P
    
    wb = xlrd.open_workbook('temp7.xls') #LOADING EXCEL FILE
    wb.sheet_names()
    sh = wb.sheet_by_index(0)
    
    first_column = sh.col_values(1) #VALUES FROM EXCEL
    second_column = sh.col_values(2) #VALUES FROM EXCEL
    

Now how do I find the frequency from this?


Answer: I'm not sure how much you know about the Fourier transform, so forgive me if
this is too much background.  
Your signal does not have "a frequency", it is but it can be thought of as the
sum of many frequencies. The Fourier transform will tell you the weights of
all the frequencies that make up your signal. Unfortunately information may be
lost when sampling from the analog (continuous time) to digital (discrete
time) domain. This puts a constraint on the information we can get about
frequency - namely that the maximum frequency component we can determine is
related to the digital sampling rate ([Nyquist-Shannon
criterion](http://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem)):

    
    
    fs > 2B
    

Where `fs` is your sampling rate (samples/unit time, typically in Hz or
something like it), and `B` is the maximum frequency of your signal. If your
signal _actually_ has frequencies higher than `B` they will be "aliased" to
some value lower than `B`.

For your problem, all you have to do is this:

    
    
    x = N.array(first_column)
    X = F.fft(x)
    

Now `X` is the frequency-domain representation of your voltage signal. The
corresponding frequency axis covers `[0, fs)`, based on the sampling theorem.
So, what is `fs`? You need to calculate that by looking at the number of
samples you have divided by the total duration of your sampled signal (note
your units here):

    
    
    fs = len(second_column) / second_column[-1]
    

Note that this representation of your signal will also (probably) be complex,
i.e. each frequency will have an associated amplitude and phase.

Hopefully this helps, and hopefully I didn't cover a bunch of stuff you
already knew.

