[Tutor] import data (txt/csv) into list/array and manipulation

Kent Johnson kent37 at tds.net
Tue Nov 11 00:36:42 CET 2008

On Mon, Nov 10, 2008 at 12:12 PM, trias <t.gkikopoulos at dundee.ac.uk> wrote:

>  I have started learning python (any online help content suggestions are
> welcome) and want to write a couple of scripts to do simple numeric
> calculations on array data.

Welcome! Have you seen

> filetype(1) I have reference files (ie file.csv) that contain three columns
> with variable rows, first column is type str contains a unique identifier
> name, and the other two columns are int type contain two reference values
> (start,stop(genomic location reference values).
>  **maybe I should import this as dictionary list**

I don't know what a dictionary list is, do you mean a list of
dictionaries? I think a list of lists is probably fine.

Python comes with a csv module that helps to read csv files. Then you
will have to convert the second two columns from string to int.

> filetype(2) The other file contains signal data in three columns, column one
> is a unique identifier type int, and the other two columns contain two type
> int values (genomic location reference values)
>  ** import this as array/list
> I want to map the location of filetype(2) with respect to filetype(1) and be
> able to do averaging of signal if I align all filetype one objects.

I don't know what you mean by this. I guess you want to search within
filetype(1) for intervals that contain the locations from filetype(2)
? This is pretty straightforward but if you have long lists it may be
slow. This recent thread has some suggestions for speeding up
searching large data sets:

It looks like you and Srinivas are trying to solve similar problems.


More information about the Tutor mailing list