0

I want to read a file which has this info in the beginning which I do not need

REGRESS_OPTIONS {
-directed=1
-rocket_run_args =+ " +QDSP6_AXIM2_PRESENT=1 +AXIM2_LOWER_ADDR=0x30000000 +AXIM2_UPPER_ADDR=0x40000000"
-rocket_run_args =+ " +maxTime=1000000 +disableAllIntDrivers=1 +disableL2DirtyEntryCheck=1"
-rocket_run_args =+ " +enableVregPreload=2 +enableQregPreload=2"
-rocket_run_args =+ " +clkRandomEnable=0 +clkTypPeriod_CORE_CLK=1000 +clkTypPeriod_AXIM_CLK=1000 +clkTypPeriod_AXIS_CLK=1000 +clkTypPeriod_AHBM_CLK=1000"
-rocket_run_args =+ " +clkTypPeriod_VPE_ASYNC_CLK=1000"
-rocket_run_args =+ " +randomizeSTID=0"
# Adding option to allow NMI exception 
-rocket_run_args =+ " +allow_nmi_exception=1 "
# Adding option to true sharing limited to a single register
-rocket_run_args =+ "+enableReferenceCheckTrust=T0:R2,T1:R2,T2:R2,T3:R2,T4:R2,T5:R2" 
-rocket_run_args =+ " +pktidMonitor=1 +schedStallMonitor=1 +set_log_level=trace +max_error=5"
-postgen = "echo QDSP6_WS_TAG=$QDSP6_WS_TAG; $WORKSPACE/verif/core/sim/scripts/perf/get_wave_args.py wave_start 1 wave_stop 1"
-prereport = "$WORKSPACE/verif/core/sim/scripts/perf/get_perf_result.py"
}

I want to read the file to buffer after discarding this part

my idea is to do it this way

with open (file_path,'r') as file:

    next(file) for 16 times 
    lines=file.readlines()        

I know its a bad idea. So please suggest me a better way to do this

Ganga
  • 195
  • 1
  • 11
  • Possible duplicate of [How to take the first N items from a generator or list in Python?](https://stackoverflow.com/questions/5234090/how-to-take-the-first-n-items-from-a-generator-or-list-in-python) – a_guest Feb 18 '19 at 06:36
  • Duplicate of https://stackoverflow.com/questions/2444538/go-to-a-specific-line-in-python – taurus05 Feb 18 '19 at 06:40
  • Possible duplicate of [Go to a specific line in Python?](https://stackoverflow.com/questions/2444538/go-to-a-specific-line-in-python) – taurus05 Feb 18 '19 at 06:40
  • 1
    Possible duplicate of [Skip first couple of lines while reading lines in Python file](https://stackoverflow.com/questions/9578580/skip-first-couple-of-lines-while-reading-lines-in-python-file) – Thierry Lathuille Feb 18 '19 at 06:42
  • @Ganga, see if the answer posted below helped? if it did, you may accept it by clicking on the tick sign beside it. cheers! – DirtyBit Feb 18 '19 at 15:19

1 Answers1

1

You could do that using Slicing:

with open (file_path,'r') as file:
   content = file.readlines()

   # you may also want to remove empty lines
   content = [l.strip() for l in content if l.strip()]

   # slice through first 16 lines    
   for line in content[16:]: 
        print(line)       
DirtyBit
  • 16,613
  • 4
  • 34
  • 55