[Tutor] Unpacking a Tuple - Can It Be Done with a CSV Line?

Seelinger, Bruce bseelinger@neteffectcorp.com
Tue, 30 Jan 2001 16:49:49 -0500


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C08B06.919E7700
Content-Type: text/plain;
	charset="iso-8859-1"

Hello,

I am writing a script which opens a file which consists of comma separated
entries similar to the example below:

value1, value2, value3, value4,  etc. etc.

The above line is read and assigned to a variable.  At that point I was
hoping it could be treated as a tuple or sequence of values.  Unfortunately,
the variable treats the entire line as a single string instead of separate
values between the commas.  Is there any way to have the line act as a tuple
which can be unpacked?  Essentially, I want to extract values from a comma
separated list of values from each line.

I am relatively new to Python and the only other language I have extensive
programming with is VMS's DCL.

Can anyone help?

Thanks in advance for any help!

Regards,

Bruce Seelinger

------_=_NextPart_001_01C08B06.919E7700
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2652.35">
<TITLE>Unpacking a Tuple - Can It Be Done with a CSV Line?</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2 FACE=3D"Arial">Hello,</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">I am writing a script which opens a =
file which consists of comma separated entries similar to the example =
below:</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">value1, value2, value3, value4,&nbsp; =
etc. etc.</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">The above line is read and assigned to =
a variable.&nbsp; At that point I was hoping it could be treated as a =
tuple or sequence of values.&nbsp; Unfortunately, the variable treats =
the entire line as a single string instead of separate values between =
the commas.&nbsp; Is there any way to have the line act as a tuple =
which can be unpacked?&nbsp; Essentially, I want to extract values from =
a comma separated list of values from each line.</FONT></P>

<P><FONT SIZE=3D2 FACE=3D"Arial">I am relatively new to Python and the =
only other language I have extensive programming with is VMS's =
DCL.</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Can anyone help?</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Thanks in advance for any help!</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Regards,</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Bruce Seelinger</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C08B06.919E7700--