I am new to python file data processing. I have the following text file having the report of a new college campus. I want to extract the data from the column "colleges" and for "book_IDs_1" for block_ABC_top which is 23. I also want to know if there is any more occurrence of block_ABC_top in the colleges column and find the value for the book IDs_1 column. Is it possible in a text file? or il have to change it to csv? How do i write a code for this data processing? Kindly help me!!
Copyright 1986-2019, Inc. All Rights Reserved.
Design Information
-----------------------------------------------------------------------------------------------------------------
| Version : (lin64) Build 2729669 Thu Dec 5 04:48:12 MST 2019
| Date : Wed Aug 26 00:46:08 2020
| Host : running 64-bit Red Hat Enterprise Linux Server release 7.8
| Command : college report
| Design : college
| Device : laptop
| Design State : in construction
-----------------------------------------------------------------------------------------------------------------
Table of Contents
-----------------
1. Information by Hierarchy
1. Information by Hierarchy
---------------------------
+----------------------------------------------+--------------------------------------------+------------+------------+---------+------+-----+
| colleges | Module | Total mems | book IDs_1 | canteen | BUS | UPS |
+----------------------------------------------+--------------------------------------------+------------+------------+---------+------+-----+
| block_ABC_top | (top) | 44 | 23 | 8 | 8 | 8 |
| (block_ABC_top_0) | block_ABC_top_0 | 5 | 5 | 5 | 2 | 9 |
+----------------------------------------------+--------------------------------------------+------------+------------+---------+------+-----+
I have a data List which has data of the colleges such as block_ABC_top, block_ABC_top_1,block_ABC_top, block_ABC_top_1...Here is my code below The problem i face is..it only takes the data for data[0]..but i have data[0] and data[2] having the same college and i expect the check to happen twice.
with open ("utility.txt", 'r') as f1:
for line in f1:
if data[x] in line:
line_values = line.split('|')
if (int(line_values[4]) == 23 or int(line_values[7]) == 8):
filecheck = fullpath + "/" + filenames[x]
print filecheck
#print "check file "+ filenames[x]
x = x + 1
f1.close()