[Tutor] Help? Making Variables out of the header row in a CSV file

Ralph H. Stoos Jr. rstoos at rochester.rr.com
Wed Jun 21 03:20:40 CEST 2006


All,

Please forgive the long question, but duty calls me to get something
done with Python that I don't want somebody to do with Microsloth Excel or Miserable
Basic.

The part I can't seem to get going has to do with making variables out
of the header row in the CSV file.  The way it needs to work is that the
first row may be of differing lengths (extra fields).  I want to have
the standalone Python script to make the variables and then allow the user
to sort the data based on the contents of the columns (i.e. pull out the
records that match one or more criteria).

The final product would allow me to select the input file, specify some thing
like the value of the "PPM" or "Grain" (and combinations thereof), and
write the output to a new CSV file.  The last bit would be some math on the contents of a couple of the fields.

Here is a snippet of the data so you can see what I am dealing with.

Machine,PurgeSuccess,PurgePrepared,PurgeStarted,PurgeCauseFaultID,PurgeModId,PurgeStopModId,ModIdJobCfg,NameJobCfg,Full_cfg,FinisherCfg,plex,PPM,PropID,AtreeNodeID,JobID,MediaID,Width,Height,Color,Weight,Caliper,Drilled,Finish,Grain,CoatingFront,CoatingBack,SW,additional_info,debuglog
1125785731,N,Y,Y,927,6,5,_2_3_4_5_6,_SFM20_IOT7_SFM7_BFM20_BFM2,_SFM20_IOT7_SFM7_BFM20_BFM2,DUAL_BFM,Simplex,120,44366,1228,392,527,279400,431800,white,75,104,FALSE,regular,y,none,none,RV0.6.5.27,,DebugMsgLog.2006_05_24.07_48_00
1125785731,Y,Y,N,1003,6,,_2_3_4_5_6,_SFM20_IOT7_SFM7_BFM20_BFM2,_SFM20_IOT7_SFM7_BFM20_BFM2,DUAL_BFM,Duplex,120,69206,75,408,29,279400,431800,white,75,104,FALSE,regular,y,none,none,RV0.6.5.27,,DebugMsgLog.2006_05_31.14_33_25A


Regards,

Ralph



More information about the Tutor mailing list