Re: CSV to matrix array

2013-04-13 Thread Oscar Benjamin
On 13 April 2013 16:30, Ana Dionísio wrote: > It's still not working. I still have one column with all the data inside, > like this: > > 2999;T3;3;1;1;Off;ON;OFF;ON;ON;ON;ON;Night;; > > How can I split this data in a way that if I want to print "T3" I would just > do "print array[0][1]"? Yo

Re: CSV to matrix array

2013-04-13 Thread cantorp
Dear Ana, your example data could be transformed into a matrix with >>>import csv >>>rows = csv.reader(open("your_data_file.csv"), delimiter=" ") >>>array = [row for row in rows] >>>array[0][3] 4 HTH Paolo Am Freitag, 12. April 2013 19:29:05 UTC+2 schrieb Ana Dionísio: > That only puts the data

Re: CSV to matrix array

2013-04-13 Thread Mark Lawrence
On 13/04/2013 16:30, Ana Dionísio wrote: It's still not working. I still have one column with all the data inside, like this: 2999;T3;3;1;1;Off;ON;OFF;ON;ON;ON;ON;Night;; How can I split this data in a way that if I want to print "T3" I would just do "print array[0][1]"? I said before

Re: CSV to matrix array

2013-04-13 Thread Ana Dionísio
It's still not working. I still have one column with all the data inside, like this: 2999;T3;3;1;1;Off;ON;OFF;ON;ON;ON;ON;Night;; How can I split this data in a way that if I want to print "T3" I would just do "print array[0][1]"? -- http://mail.python.org/mailman/listinfo/python-list

Re: CSV to matrix array

2013-04-13 Thread giacomo boffi
Ana Dionísio writes: > Hello! > > I have a CSV file with 20 rows and 12 columns and I need to store it > as a matrix. array=numpy.array([row for row in csv.reader(open('Cenarios.csv'))]) NB: i used "array=" as in your sample code, BUT -- http://mail.python.org/mailman/listinfo/python-list

Re: CSV to matrix array

2013-04-12 Thread Miki Tebeka
> I have a CSV file with 20 rows and 12 columns and I need to store it as a > matrix. If you can use pandas, the pandas.read_csv is what you want. -- http://mail.python.org/mailman/listinfo/python-list

Re: CSV to matrix array

2013-04-12 Thread Javier Miranda
Keep the flattened data array others suggested, and then just split it like this: *(replace `example_data`, `_array`, and `columns`)* >>> example_data = range(15) >>> split_array = lambda _array, colums: \ . . .[_array[i:i + colums] for i in \ . . .xrange(0, len(_array),

Re: CSV to matrix array

2013-04-12 Thread Dave Angel
On 04/12/2013 01:29 PM, Ana Dionísio wrote: That only puts the data in one column, I wanted to separate it. For example: data in csv file: 1 2 3 4 5 7 8 9 10 11 a b c d e I wanted an array where I could pick an element in each position. In the case above if I did print array[0][3] it would pi

Re: CSV to matrix array

2013-04-12 Thread rusi
On Apr 12, 10:12 pm, Ana Dionísio wrote: > Hi, thanks for yor answer! ;) > > Anyone has more suggestions? My suggestions: 1. Tell us what was lacking in Mark's suggestion (to use loadtxt) 2. Read his postscript (for googlegroup posters). [In case you did not notice your posts are arriving in dou

Re: CSV to matrix array

2013-04-12 Thread Ana Dionísio
That only puts the data in one column, I wanted to separate it. For example: data in csv file: 1 2 3 4 5 7 8 9 10 11 a b c d e I wanted an array where I could pick an element in each position. In the case above if I did print array[0][3] it would pick 4 -- http://mail.python.org/mailman/lis

Re: CSV to matrix array

2013-04-12 Thread Jean-Michel Pichavant
- Original Message - > Hello! > > I have a CSV file with 20 rows and 12 columns and I need to store it > as a matrix. I already created an array with zeros, but I don't know > how to fill it with the data from the csv file. I have this script: > > import numpy > from numpy import array >

Re: CSV to matrix array

2013-04-12 Thread Ana Dionísio
Hi, thanks for yor answer! ;) Anyone has more suggestions? -- http://mail.python.org/mailman/listinfo/python-list

Re: CSV to matrix array

2013-04-12 Thread Mark Lawrence
On 12/04/2013 15:22, Ana Dionísio wrote: Hello! I have a CSV file with 20 rows and 12 columns and I need to store it as a matrix. I already created an array with zeros, but I don't know how to fill it with the data from the csv file. I have this script: import numpy from numpy import array fr

CSV to matrix array

2013-04-12 Thread Ana Dionísio
Hello! I have a CSV file with 20 rows and 12 columns and I need to store it as a matrix. I already created an array with zeros, but I don't know how to fill it with the data from the csv file. I have this script: import numpy from numpy import array from array import * import csv input = open(