forked from deseram07/Capral-OCR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getdata.py
26 lines (23 loc) · 759 Bytes
/
getdata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Extracts the ID's of dies which are out of the vertex library
#from database file and saves in a text file
#
#Author: Buddhika De Seram
from dbfpy import dbf
import os
# hardcode the location of database file in computer
os.chdir('E:\\Code\\Capral-OCR\\database') #switches to the location of the database file in the computer
#hardcode the database file including the location
dbf1 = dbf.Dbf('E:\\Code\\Capral-OCR\\database\\SEGMENT.dbf', new=False) #loading database file
def getdata():
f = open('available.txt', 'w')
counter = 0
for rec in dbf1:
if rec['P_QTY'] == 0:
counter = 0
for i in rec['P_CODE']:
counter += 1
if i.isalpha() or i.isdigit():
f.write(i)
if len(rec['P_CODE']) == counter:
f.write('\n')
f.close()