What else? (!)
In the pffreadcsv program, I check for "Block" in the first "column"
What if that line does not start with "Block" - ?
I can modify the read as follows
# what if Block is NOT in the first column?
# read the file line by line
nstart = 0
for i in lines:
nstart = nstart + 1
# the split command splits the line into individual elements as it were -
# so a line that is 1,2,1200,500 will be split into 1 2 1200 and 500 using the comma as a separator
thisline = i.split(',')
# if I want to look for a line that has 'Block' (because I happen to know the data comes after this line)
nchars = len(thisline)
for j in range(nchars):
if (str(thisline[j]) == 'Block'):
print ("In your file ", datafile, " Block shows up in line ", nstart, ' at position ', j )
break;
else:
continue
So you can "look" for any character you want on that line ... (!)
(this makes it a bit more general than what I had)
the code as I have is just slightly off ... (anyone notice?) (I will post a correction later!)
ReplyDelete