Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Vilhelm-Ion Praisach
  Where is Vilhelm-Ion Praisach?
 Resita
 Romania
 Vilhelm-Ion Praisach
 To: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Canada
 Pete Sass
 Tags
Subject: RE: Old Unix Fun Question
Thread ID: 416112 Message ID: 416122 # Views: 60 # Ratings: 2
Version: Visual FoxPro 9 SP2 Category: Linux and VFP
Date: Monday, December 22, 2014 7:30:01 AM         
   


> Hi Again Folks,
>
> This is a question for advise, opinion or suggestions. Any comments would be appreciated.
>
> Here is the scenario....
> Old Unix/Linux system aging over 25 years old and involves a very old accounting system.
> The data files are of unknown origin and the developer used a file naming convention of
> datafilename.I and datafileName.D
> .I are the invoice header files and .D are the associated invoice details files.
> The data files are binary data files and for each data file there is a filename.C that has
> the field layout and field type in it.
>
> In looking through the data files and header there is no hint of what type of data files there
> are and apparently the original developer dropped death or got hit by a bus year and years ago.
> The client running this system has absolutely no idea of the files, there origin, of where they
> came from or who made them.
>
> Now the task at hand is to port the data into something structured like a SQL Server table of
> CSV file that can be sucked in.
>
> I have reviewed the data files and can find nothing anywhere as to what type of binary files they
> are.
> On a Linux system I have I cannot open these files in VI or do anything with them at all. Further more
> there are no reports in the system and no way to print to a null Unix printer and CAT the print file
> to a txt file.
>
> I have found if I run a 4-5 phase stripper routine and then run a time consuming parser to code I can
> probably get the data out after litterly days of programming.
> There are dozens of data file format types so the stripper and parsing routines would have to be recoded
> to get the data out for each type.
>
>
> By the was I have around 6 GIG of data spit across over 600 data files of various structures.
>
>
> MY FIRST QUESTION OR CONCERN FOR YOU ALL . . .
> WHAT DO YOU THINK? ANYTHING I MAY HAVE MISSED? LIKE A UTILITY THAT CAN READ OBSCURE FILE HEADERS AND
> DETERMINE WHAT TYPE OF BINARY FILE THESE ARE?
>
>
> MY SECOND QUESTION OR CONCERN FOR YOU ALL . . .
> HOW DO I PROVIDE AN ESTIMATE FOR THE CLIENT FOR SOMETHING LIKE THIS? OR DO I JUST SAY XX DOLLARS PER HOUR
> FOR AS LONG AS IT TAKES? RIGHT NOW I HAVE NO IDEA WHAT I WILL RUN INTO UNTIL I AM WORKING ON ONE OF THE
> DATA FILE TYPES AND GET INTO THE STRIPPING AND PARSING ROUTINES.
>
>
> ALL COMMENTS AND SUGGUESTIONS WELCOME, BECUASE THIS IS LOOKING LIKE A FULL WINTER PROJECT!
>
>
>
> Pete "the IceMan", from the Great White North of Canada.
> www.marathongriffincomputers.com

It's possible that your files have no header.
There could be a simple set of structures, stored one after another, and the structure of the file record is coded in the program.

Similar with This VFP code
LOCAL lcFName,loRecord
lcFName = 'test.d'
lnF=createfile(m.lcFName)
loRecord = CREATEOBJECT("MyFileRecord",12,"John",DATE(1990,12,25))
populatefile(m.lcFName,m.loRecord)
loRecord = CREATEOBJECT("MyFileRecord",10,"Jane",DATE(1991,12,31))
populatefile(m.lcFName,m.loRecord)
listfile(m.lcFName)


FUNCTION createfile(tcFName as String)
	LOCAL lnF
	lnF = FCREATE('test.d')
	FCLOSE(m.lnF)
	RETURN m.lnF
ENDFUNC

FUNCTION populatefile(tcFName as String,toRecord as MyFileRecord)
	LOCAL lnF
	lnF = FOPEN(m.tcFName,12)
	IF m.lnF >= 0
		FSEEK(m.lnF,0,2)
		FWRITE(m.lnF,BINTOC(m.toRecord.nId))
		FWRITE(m.lnF,m.toRecord.cName + CHR(0))
		FWRITE(m.lnF,TRANSFORM(m.toRecord.dBirth))
		FCLOSE(m.lnF)
	ENDIF
	RETURN m.lnF
ENDFUNC

FUNCTION listfile(tcFName as String)
	LOCAL loRecord as MyFileRecord,lcName,lcChar
	loRecord = CREATEOBJECT("MyFileRecord")
	lnF = FOPEN(m.tcFName,12)
	IF m.lnF >= 0
		DO WHILE !FEOF(m.lnF)
			loRecord.nId = CTOBIN(FREAD(m.lnF,4))
			lcName = ""
			lcChar = FREAD(m.lnF,1)
			DO WHILE m.lcChar <> CHR(0)
				lcName = m.lcName + m.lcChar
				lcChar = FREAD(m.lnF,1)
			ENDDO
			loRecord.cName = m.lcName
			loRecord.dBirth = CTOD(FREAD(m.lnF,10))

			?loRecord.nId,loRecord.cName,loRecord.dBirth
		ENDDO
		FCLOSE(m.lnF)
	ENDIF
	RETURN m.lnF
ENDFUNC
	

DEFINE CLASS MyFileRecord as Custom
	nId = 0
	cName = ""
	dBirth = {}
	PROCEDURE Init
		LPARAMETERS tnId,tcName,tdBirth
		This.nId = m.tnId
		This.cName = m.tcName
		This.dBirth = m.tdBirth
	ENDPROC
ENDDEFINE


Respectfully

ENTIRE THREAD

Old Unix Fun Question Posted by Pete Sass @ 12/21/2014 10:31:10 PM
RE: Old Unix Fun Question Posted by Vilhelm-Ion Praisach @ 12/22/2014 7:30:01 AM
RE: Old Unix Fun Question Posted by Pete Sass @ 12/22/2014 4:08:36 PM
RE: Old Unix Fun Question Posted by Zia Mughal @ 12/22/2014 9:19:06 AM
RE: Old Unix Fun Question Posted by Pete Sass @ 12/22/2014 4:12:38 PM
RE: Old Unix Fun Question Posted by PowerGod @ 12/22/2014 3:32:03 PM
RE: Old Unix Fun Question Posted by Pete Sass @ 12/22/2014 4:10:57 PM