Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Multi-arrays python

Reply
Thread Tools

Multi-arrays python

 
 
bbarbero@inescporto.pt
Guest
Posts: n/a
 
      10-07-2009
Hi again!

After testing the whole day, I have got my goals from the last email,
but as always, another issues came up! and now that Ive been able to
save a list of list (or multi-arrays) as below :

['100.mp3\n' '10008.mp3\n' '10005.mp3\n' '10001.mp3\n' '10006.mp3\n']
['10001.mp3\n' '10005.mp3\n' '100.mp3\n' '10008.mp3\n' '10006.mp3\n']
['10005.mp3\n' '10001.mp3\n' '100.mp3\n' '10008.mp3\n' '10006.mp3\n']
['10006.mp3\n' '10005.mp3\n' '10001.mp3\n' '100.mp3\n' '10008.mp3\n']
['10008.mp3\n' '100.mp3\n' '10001.mp3\n' '10005.mp3\n' '10006.mp3\n']

I am not able to manipulate it again! I read it with:
Myfile.read() and all what I get is a str type data, what make my aim
very difficult to reach! What I want, is just to read one line(one
specific line, so I wouldnt have to read the whole file) and to get
the numbers of the songs from that line. Maybe I should save the
information in another way... But I just get those lines as lists, and
write them in a file. Is there a better way? I am very receptive to
suggestions! Thanks again for your help!

Best regards,
Bea Mora

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
 
Reply With Quote
 
 
 
 
Piet van Oostrum
Guest
Posts: n/a
 
      10-14-2009
>>>>> http://www.velocityreviews.com/forums/(E-Mail Removed) (b) wrote:

>b> Hi again!
>b> After testing the whole day, I have got my goals from the last email, but
>b> as always, another issues came up! and now that Ive been able to save a
>b> list of list (or multi-arrays) as below :


>b> ['100.mp3\n' '10008.mp3\n' '10005.mp3\n' '10001.mp3\n' '10006.mp3\n']
>b> ['10001.mp3\n' '10005.mp3\n' '100.mp3\n' '10008.mp3\n' '10006.mp3\n']
>b> ['10005.mp3\n' '10001.mp3\n' '100.mp3\n' '10008.mp3\n' '10006.mp3\n']
>b> ['10006.mp3\n' '10005.mp3\n' '10001.mp3\n' '100.mp3\n' '10008.mp3\n']
>b> ['10008.mp3\n' '100.mp3\n' '10001.mp3\n' '10005.mp3\n' '10006.mp3\n']


>b> I am not able to manipulate it again! I read it with:
>b> Myfile.read() and all what I get is a str type data, what make my aim very
>b> difficult to reach! What I want, is just to read one line(one specific
>b> line, so I wouldnt have to read the whole file) and to get the numbers of
>b> the songs from that line. Maybe I should save the information in another
>b> way... But I just get those lines as lists, and write them in a file. Is
>b> there a better way? I am very receptive to suggestions! Thanks again for
>b> your help!


You are unclear about the syntax of your file. What is a line? Is this a
line?
['100.mp3\n' '10008.mp3\n' '10005.mp3\n' '10001.mp3\n' '10006.mp3\n']

If so what do the \n after the filenames mean? Is \n a newline, or is it
a backslash followed by 'n'? In the first case then every filename is on
a separate line. So then you are mixing two concepts of line.

Anyhow you would make your life easier by getting rid of the \n's.

If all your filenames are numeric with the extension mp3 then the
following gives you a list of the filenames from a line:

In [31]: re.findall('[0-9]+\.mp3', line)
Out[31]: ['100.mp3', '10008.mp3', '10005.mp3', '10001.mp3', '10006.mp3']

--
Piet van Oostrum <(E-Mail Removed)>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 R. David Murray Python 0 01-17-2011 02:23 PM
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 Senthil Kumaran Python 0 01-17-2011 10:31 AM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Martin v. L÷wis Python 0 03-01-2008 10:51 PM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Paul Moore Python 0 03-01-2008 10:39 PM
Searching comp.lang.python/python-list@python.org (was: UTF-8) skip@pobox.com Python 0 03-10-2007 02:50 PM



Advertisments