read in a list in a file to list
rosuav at gmail.com
Sun Apr 9 17:52:56 EDT 2017
On Mon, Apr 10, 2017 at 7:22 AM, john polo <jpolo at mail.usf.edu> wrote:
> Thanks for the reply. I looked back through the methods for strings. I also
> looked at the csv module, but I couldn't tell which one of those would help.
> The small .txt file does have commas, but with the weird form of listname =
>  , , , etc. for a .csv, I don't know how that would be read in a
> like a .csv. But now that I think about it, datObj2 in my script prints just
> the list elements, so maybe the 'listname=' part wouldn't affect it...
Hmm, interesting. Perhaps ast.literal_eval will help here? Parse off
the bit after the first equals sign and feed it to literal_eval.
You'll get back a tuple.
More information about the Python-list