Hey Dave, you're right. I worked through this with a for loop and set the contents of a dict's key as the input.
Thanks! Leam On Thu, Aug 15, 2013 at 8:28 PM, Dave Angel <da...@davea.name> wrote: > leam hall wrote: > > > I'm trying to take input from a file (CSV spreadsheet) and use the first > > line inputs (header) as the names of lists. So far I'm not successful. > :) > > > > How do I take line_list[0], the result of "line.split(',')" and use it as > > the name of a list? Does that make sense? > > > > No, it doesn't make sense. You're trying to define a variable that has > a name determined not by your source, but by a name in line 0 of the csv > file. How then are you going to use that variable? > > There are two possibilities: Either you actually know those names and > are using them in your code, or the names won't be known till runtime. > > If the latter, then make a dictionary of lists, > > mydict = {} > for item in line_list: > mydict[item] = [] > > and then populate those lists from each line of the file. > > Now, if you're sure you know what the names are to be, then: > > names = mydict["name"] > addresses = mydict["address"] > > or whatever. > > > > > -- > DaveA > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Mind on a Mission <http://leamhall.blogspot.com/>
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor