Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #56274

Re: how to read list from file

References <fbc6e512-88fa-4de0-80d3-6757fcc52af4@googlegroups.com> <236e2bfa-94a2-4c6b-a6e7-7105370375fc@googlegroups.com>
From Ravi Sahni <ganeshsahni07@gmail.com>
Date 2013-10-06 23:08 +0530
Subject Re: how to read list from file
Newsgroups comp.lang.python
Message-ID <mailman.790.1381082860.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Oct 6, 2013 at 10:27 PM, Harvey Greenberg <hjgreenberg@gmail.com> wrote:
> On Saturday, October 5, 2013 7:08:08 PM UTC-6, Harvey Greenberg wrote:
>> I am looping as for L in file.readlines(), where file is csv.
>>
>>
>>
>> L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3], 10] Note that the first item is a dir and 2nd is a list, so parsing with split doesn't work.  Is there a way to convert L, which is a string, to the list of 3 items I want?
>
> Yay!!!! It worked.  Thanks!

Which method working?
Literal_eval method? JSON method? Some third method?

[I am newbie so interested. Please to excuse!!]
-- 
Ravi

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

how to read list from file Harvey Greenberg <hjgreenberg@gmail.com> - 2013-10-05 18:08 -0700
  Re: how to read list from file Tim Chase <python.list@tim.thechases.com> - 2013-10-05 20:24 -0500
    Re: how to read list from file Roy Smith <roy@panix.com> - 2013-10-05 21:35 -0400
    Re: how to read list from file Harvey Greenberg <hjgreenberg@gmail.com> - 2013-10-06 09:41 -0700
      Re: how to read list from file Harvey Greenberg <hjgreenberg@gmail.com> - 2013-10-06 09:46 -0700
      Re: how to read list from file Ravi Sahni <ganeshsahni07@gmail.com> - 2013-10-06 22:20 +0530
      Re: how to read list from file Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-10-07 09:04 +0300
  Re: how to read list from file Roy Smith <roy@panix.com> - 2013-10-05 21:34 -0400
  Re: how to read list from file Terry Reedy <tjreedy@udel.edu> - 2013-10-06 02:24 -0400
  Re: how to read list from file Harvey Greenberg <hjgreenberg@gmail.com> - 2013-10-06 09:57 -0700
    Re: how to read list from file Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-06 18:24 +0100
    Re: how to read list from file Ravi Sahni <ganeshsahni07@gmail.com> - 2013-10-06 23:08 +0530

csiph-web