Hi,

have you tried the examples that I have provided a couple days ago,

see below? I cannot see why it should not work. These are the absolute

basics that you need to understand.

Btw, there is no need to use csv2rec unless you want/need column or row headers.

Here's a full script that does what you want. Now, please take the

time and work through the example that I have provided. In case you

need further help, please don't start a new thread but reply to this

one.

Best regards,

Daniel

# -*- coding: utf-8 -*-

import matplotlib.pyplot as plt

import pylab

import scipy

datafile1 = 'ch1_s1_lrr.csv'

datafile2 = 'ch1_s1_baf.csv'

## create dummy data

data = pylab.rand(10000,12)

pylab.savetxt(datafile1, data, delimiter=';')

pylab.savetxt(datafile2, data, delimiter=';')

## load data and transpose

a1 = pylab.loadtxt(datafile1, comments='#', delimiter=';').T

print 'loading', datafile1

b1 = pylab.loadtxt(datafile2, comments='#', delimiter=';').T

print 'loading', datafile2

## axis limits

#v1 = [0,98760,0,1]

#v2 = [0,98760,-2,2]

v1 = [0,1]

v2 = [-2,2]

plt.close('all')

plt.figure()

plt.subplot(2,1,1)

#plt.axis(v2)

plt.ylim(v2)

#plt.plot(a1, 'r.')

for i in range(6):

plt.plot(a1[i])

plt.subplot(2,1,2)

#plt.axis(v1)

plt.ylim(v1)

#plt.plot(b1, 'b.')

## need masked arrays here

## http://physics.nmt.edu/~raymond/software/python_notes/paper003.html

m = b1 >= 0.05

b1masked = scipy.ma.array(b1,mask=m)

## print first two cols

print b1masked[0:2]

for i in range(6,12):

plt.plot(b1masked[i])

plt.show()

2011/6/3 Karthikraja Velmurugan <velmurugan.karthikraja@...287...>:

import matplotlib.pyplot as plt

import pylab

datafile1 = 'ch1_s1_lrr.csv'

datafile2 = 'ch1_s1_baf.csv'

a1 = pylab.loadtxt(datafile1, comments='#', delimiter=';')

b1 = pylab.loadtxt(datafile2, comments='#', delimiter=';')

v1 = [0,98760,0,1]

v2 = [0,98760,-2,2]

plt.figure(1)

plt.subplot(2,1,1)

print 'loading', datafile1

plt.axis(v2)

plt.plot(a1, 'r.')

plt.subplot(2,1,2)

print 'loading', datafile2

plt.axis(v1)

plt.plot(b1, 'b.')

plt.show()

2011/5/30 Daniel Mader <danielstefanmader@...982...>:

## ···

Hi,

the content of the CSV is stored as an array after reading. You can

simply access rows and columns like in Matlab:

firstrow = a1[0]

firstcol = a1.T[0]

The .T transposes the array.

The second element of the third row would be

elem32 = a1[2][1]

which is equivalent to

elem32 = a1[2,1]

A range of e.g. rows 3 to 6 is

range36 = a1[2:6]

Please have a look here for getting started with scipy/numpy:

http://pages.physics.cornell.edu/~myers/teaching/ComputationalMethods/python/arrays.html

and

http://www.scipy.org/NumPy_for_Matlab_Users

Hope this helps,

Daniel

2011/5/27 Karthikraja Velmurugan <velmurugan.karthikraja@...287...>:

Hello Daniel,

The code you have given is simple and works fab. Thank you very much. But I

wasn't able to find an example which accesses the columns of a CSV files

when I import data through "datafile="filename.csv"" option. It will be

great if you could help with accessing individual columns. What excatly I am

looking for is to access individual coulmns (of the same CSV file), do

calculations using the two coumns and plot them into seperate subplots of

the same graph.

I modified the script a lil bit. Please find it below:

import matplotlib.pyplot as plt

import pylab

datafile1 = 'ch1_s1_lrr.csv'

datafile2 = 'ch1_s1_baf.csv'

a1 = pylab.loadtxt(datafile1, comments='#', delimiter=';')

b1 = pylab.loadtxt(datafile2, comments='#', delimiter=';')

v1 = [0,98760,0,1]

v2 = [0,98760,-2,2]

plt.figure(1)

plt.subplot(4,1,1)

print 'loading', datafile1

plt.axis(v2)

plt.plot(a1, 'r.')

plt.subplot(4,1,2)

print 'loading', datafile2

plt.axis(v1)

plt.plot(b1, 'b.')

plt.show()

Thank you very much in advance for your time and suggestions.

Karthik