[Tutor] .txt matrix import

Joel Goldstick joel.goldstick at gmail.com
Wed Aug 7 23:46:33 CEST 2013


On Wed, Aug 7, 2013 at 12:38 PM, Joshua Kim <joshkim.319 at gmail.com> wrote:
> Hello,
>
> This is my first time using Tutor, so I apologize for any fallacies I may be
> making; my problem involves opening a .txt file which contains several lines
> of descriptive information followed by a tab delimited matrix of numerical
> values… I am trying to find an effective way in which to skip the first 'X'
> number of lines in the .txt file (54 in my case) and input the columns of
> data into individual arrays (note the 55th line denotes the title of the
> column, so preferably I would like to have python use those values as the
> names to the individual array, but I am unsure of how involved that may
> become)
>
>
> Any hints/suggestions/pointers would be appreciated.
>

If you use the file method readlines() it will read the complete file
into a list of each line in the file.  From there you can start
processing from the 54th item in the list.

You should also look up the csv module which implies that is it for
processing comma separated value data, but it can also work with tab
separated values.

> Thanks
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Joel Goldstick
http://joelgoldstick.com


More information about the Tutor mailing list