Re: Problem to read from array

2015-11-24 Thread Peter Otten
Crane Ugly wrote: > I always try to have code that easy to read. That's laudable, code is a means of communication. > At least for myself. and only for yourself, unfortunately. Recommended read: https://www.python.org/dev/peps/pep-0008/ -- https://mail.python.org/mailman/listinfo/python-l

Re: Problem to read from array

2015-11-24 Thread Crane Ugly
It is nothing more but naming convention. This code was part of the function. Actually, in the final version I removed that "f" and changed some names of variables to shorter versions. It is all about your own preferences towards readability of the code and ability of visual capture of the code.

Re: Problem to read from array

2015-11-23 Thread sohcahtoa82
On Monday, November 23, 2015 at 12:58:49 PM UTC-8, Crane Ugly wrote: > Thank you all. > Here is the last piece of code that caused me so much troubles but now > working the way I wanted it: > > fRawData = [] > with open(fStagingFile2) as fStagingFile2FH: > fRawData = [l

Re: Problem to read from array

2015-11-23 Thread Crane Ugly
Thank you all. Here is the last piece of code that caused me so much troubles but now working the way I wanted it: fRawData = [] with open(fStagingFile2) as fStagingFile2FH: fRawData = [line.strip() for line in fStagingFile2FH.readlines()] # This is

Re: Problem to read from array

2015-11-21 Thread Nathan Hilterbrand
On 11/21/2015 10:26 AM, BartC wrote: On 21/11/2015 10:41, vostrus...@gmail.com wrote: Hi, I have a file with one parameter per line: a1 b1 c1 a2 b2 c2 a3 b3 c3 ... The parameters are lines of characters (not numbers) I need to load it to 2D array for further manipulations. So far I managed to

Re: Problem to read from array

2015-11-21 Thread BartC
On 21/11/2015 10:41, vostrus...@gmail.com wrote: Hi, I have a file with one parameter per line: a1 b1 c1 a2 b2 c2 a3 b3 c3 ... The parameters are lines of characters (not numbers) I need to load it to 2D array for further manipulations. So far I managed to upload this file into 1D array: Parame

Re: Problem to read from array

2015-11-21 Thread Laura Creighton
In a message of Sat, 21 Nov 2015 15:22:55 +0100, Laura Creighton writes: >At this point you might get a bit frustrated. Python is happily telling >you that you don't have a newarray[0][0] which is hardly news to you who >was trying to initialise the thing. My bad. I was thinking about 2 dimentio

Re: Problem to read from array

2015-11-21 Thread Laura Creighton
In Python we don't write while loops that often. instead we do: for i in range(NumberOfColumns): for j in range(NumberOfRows): do_something() But for the particular case that you are after, constructing lists, we have something even neater -- list comprehensions. So you might write:

Re: Problem to read from array

2015-11-21 Thread Peter Otten
vostrus...@gmail.com wrote: > Hi, > I have a file with one parameter per line: > a1 > b1 > c1 > a2 > b2 > c2 > a3 > b3 > c3 > ... > The parameters are lines of characters (not numbers) > > I need to load it to 2D array for further manipulations. > So far I managed to upload this file into 1D arra

Problem to read from array

2015-11-21 Thread vostrushka
Hi, I have a file with one parameter per line: a1 b1 c1 a2 b2 c2 a3 b3 c3 ... The parameters are lines of characters (not numbers) I need to load it to 2D array for further manipulations. So far I managed to upload this file into 1D array: ParametersRaw = [] with open(file1) as fh: Parameters