Click here to Skip to main content
15,888,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Am new to python and am trying to generate multiple filelist by reading a master file.
//filelist.txt @library gpu /hello/this/is/file/path1/topmod.vhd /hello/this/is/file/path1/midmod.vhd /hello/this/is/file/path1/lowmod.vhd

@library cells_lib /hello/this/is/file/path2/ver1/ver1.v: +libext+.v +define+functional +define+no_unit_delay +define+PWR_OFF +define+VEND1 /hello/this/is/file/path2/ver2/ver2.v: +libext+.v +define+functional +define+no_unit_delay +define+PWR_OFF +define+VEND1 /hello/this/is/file/path2/ver3/ver3.v: +libext+.v +define+functional +define+no_unit_delay +define+PWR_OFF +define+VEND1 /hello/this/is/file/path2/ver4/ver4.v: +libext+.v +define+functional +define+no_unit_delay +define+PWR_OFF +define+VEND1

@library cpu /hello/this/is/file/path3/topmod.v /hello/this/is/file/path3/midmod.v /hello/this/is/file/path3/lowmod.v

@library io_lib /hello/this/is/file/path5/mod5.vhd /hello/this/is/file/path5/midmod5.vhd /hello/this/is/file/path5/lowmod5.vhd

this is my code which I think is nothing, but any pointers will be great help please?
Python
file_view =[]
with open('filelist.txt', 'r') as filehandle:
    for line in filehandle:
    stripped_line = line.strip()
    line_list = stripped_line.split()
    file_view.append(line_list)
    print(file_view)

I need something like this for each at library section
output required gpu.f => should contain only list of files under at library gpu cells_lib.f cpu.f io_lib.f

how do I achieve this please, any pointers will be helpful.

Thanks in advance

What I have tried:

Python
file_view =[]
with open('filelist.txt', 'r') as filehandle:
    for line in filehandle:
    stripped_line = line.strip()
    line_list = stripped_line.split()
    file_view.append(line_list)
    print(file_view)
Posted
Updated 20-Dec-20 9:48am
v2
Comments
Richard MacCutchan 9-Dec-20 4:39am    
You need to split the data from each set into its different parts, and create a list of filenames. The ones labelled gpu, cpu and io_lib seems fairly straightforward, just use string.split. The cells_lib set is a bit more complicated, and it is not clear what the fields starting with plus signs are for.

1 solution

If I've got this right, I think there is a mistake in the code given. This is not an answer but I would think you get an error from this because there is no indentation after your for line in filehandle: statement. Don't downcount be if I'm wrong.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900