Michael Langford wrote:
> A neater way to do it looks like:
>
> dic2 = {}
> countOfVars=40
> for line in file('foo.dat'):
> tokens = line.split()
> dval = tokens[0]
> ls = []
> for i in range(1,countOfVars+1):
> ls.append(float(tokens[i]))
> dic2[dval]=tuple(ls)
> p
Bryan Fodness wrote:
> it doesn't fix the problem, now it says there is a syntax error on the
> equal sign.
Please, post your code and the exact error message and traceback! Don't
make us guess what you are doing!
My guess is you forgot the closing ) but I have no way to know for sure.
Kent
>
Using the attached foo.dat and no linebreaks, what you're doing works
perfectly:
dic2 = {}
for line in file('foo.dat'):
d, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10, fs11, fs12, fs13,
fs14, fs15, fs16, fs17, fs18, fs19, fs20, fs21, fs22, fs23, fs24, fs25,
fs26, fs27, fs28, fs29, fs30, f
it works well if it is on the same line, but I would like to wrap it for
readability
On 10/21/07, Bryan Fodness <[EMAIL PROTECTED]> wrote:
>
> it doesn't fix the problem, now it says there is a syntax error on the
> equal sign.
>
> On 10/21/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
> >
> >
> > "Br
it doesn't fix the problem, now it says there is a syntax error on the equal
sign.
On 10/21/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
>
>
> "Bryan Fodness" <[EMAIL PROTECTED]> wrote in
>
> >d, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10,
> >fs11, fs12, fs13, fs14, fs15, fs16, fs17, f
"Bryan Fodness" <[EMAIL PROTECTED]> wrote in
>d, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10,
>fs11, fs12, fs13, fs14, fs15, fs16, fs17, fs18, fs19,
>fs20, fs21, fs22, fs23, fs24, fs25, fs26, fs27, fs28,
>fs29, fs30, fs31, fs32, fs33, fs34, fs35, fs36, fs37,
>fs38, fs39
Here is my code.
dic2 = {}
for line in file('21Ex6MV_tmr.dat'):
d, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10,
fs11, fs12, fs13, fs14, fs15, fs16, fs17, fs18, fs19,
fs20, fs21, fs22, fs23, fs24, fs25, fs26, fs27, fs28,
fs29, fs30, fs31, fs32, fs33, fs34, fs35, fs36, fs37,
If the ease of use is the only answer then the size of the file should not
matter ideally. btw, how large is the file ? is it in MBs or GBs ? For
performance reasons, typically you should not have any problems using either
dictionary, array or list for file size of few KBs.
Like Kent said, if you
Bryan Fodness wrote:
> The data file is larger than shown, and I was wondering if it would be
> better to populate an array or create a dictionary. Which would be
> easier?
>
A dictionary is an array with an index, if you need an index into your
data, use a dictionary, if not use an array.
>
The data file is larger than shown, and I was wondering if it would be
better to populate an array or create a dictionary. Which would be easier?
On 10/19/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
>
> Bryan Fodness wrote:
> > I have a data file that I would like to extract data from:
> >
> > F
Bryan Fodness wrote:
> I have a data file that I would like to extract data from:
>
> FS 1 2 3 4 5
> 1.5 1.000 1.000 1.000 1.000 1.000
> 2.0 0.985 0.994 0.997 0.996 0.996
> 2.5 0.967 0.976 0.981 0.981 0.982
> 3.0 0.949 0.958 0.965 0.966 0.967
> 3.
I have a data file that I would like to extract data from:
FS 1 2 3 4 5
1.5 1.000 1.000 1.000 1.000 1.000
2.0 0.985 0.994 0.997 0.996 0.996
2.5 0.967 0.976 0.981 0.981 0.982
3.0 0.949 0.958 0.965 0.966 0.967
3.5 0.925 0.937 0.945 0.948 0.
12 matches
Mail list logo